details: http://hugin.hg.sourceforge.net/hgweb/hugin/libpanorama/hgrepo/h/hu/hugin/libpanorama/rev/f60c5c650ba3
changeset: 0:f60c5c650ba3
user: dangelo <dangelo@...>
date: Tue Apr 10 09:34:34 2007 +0000
description:
directory for Daniels parser
details: http://hugin.hg.sourceforge.net/hgweb/hugin/libpanorama/hgrepo/h/hu/hugin/libpanorama/rev/430d1a65a3fc
changeset: 1:430d1a65a3fc
user: dmg <dmg@...>
date: Tue Apr 10 18:03:31 2007 +0000
description:
First commit
details: http://hugin.hg.sourceforge.net/hgweb/hugin/libpanorama/hgrepo/h/hu/hugin/libpanorama/rev/6295f8baedd8
changeset: 2:6295f8baedd8
user: dangelo <dangelo@...>
date: Wed Apr 11 09:45:53 2007 +0000
description:
added CMake based build environment and moved main()
from from tpaser.c to testparser.c
details: http://hugin.hg.sourceforge.net/hgweb/hugin/libpanorama/hgrepo/h/hu/hugin/libpanorama/rev/f87edd0e4234
changeset: 3:f87edd0e4234
user: dmg <dmg@...>
date: Wed Apr 18 16:28:05 2007 +0000
description:
2007-04-18 dmg <dmg@...>
>
> * tparser.c, tparser.h: Renamed some functions to the tlalli naming
> standards. Added functions to parse projection parameters. Added
> functions to de-reference variables. Added a function to dump the
> content of the script variable. Fixed some bugs.
>
> * tparserprivate.h: Added this file to keep any declarations that
> are only required to by parser.
>
> * parser.y: Clear newly allocated memory for image specs
>
> * testparser.c: Added logic to dereference variables. Moved
> dumping of variables to a function in tparser.c
>
>
details: http://hugin.hg.sourceforge.net/hgweb/hugin/libpanorama/hgrepo/h/hu/hugin/libpanorama/rev/511c8509ec12
changeset: 4:511c8509ec12
user: dmg <dmg@...>
date: Fri Apr 27 23:48:29 2007 +0000
description:
first commit of the projections library
details: http://hugin.hg.sourceforge.net/hgweb/hugin/libpanorama/hgrepo/h/hu/hugin/libpanorama/rev/db53a4c50954
changeset: 5:db53a4c50954
user: dangelo <dangelo@...>
date: Mon May 28 19:45:26 2007 +0000
description:
added simple wrapper to generate panotools transform stacks using the new parser
details: http://hugin.hg.sourceforge.net/hgweb/hugin/libpanorama/hgrepo/h/hu/hugin/libpanorama/rev/66c04bd8b998
changeset: 6:66c04bd8b998
user: dangelo <dangelo@...>
date: Mon May 28 19:49:21 2007 +0000
description:
details: http://hugin.hg.sourceforge.net/hgweb/hugin/libpanorama/hgrepo/h/hu/hugin/libpanorama/rev/495361a4aeac
changeset: 7:495361a4aeac
user: dangelo <dangelo@...>
date: Wed May 30 17:44:31 2007 +0000
description:
fixed a,b,c order, renamed transform functions
details: http://hugin.hg.sourceforge.net/hgweb/hugin/libpanorama/hgrepo/h/hu/hugin/libpanorama/rev/7dd4fbc8f7b4
changeset: 8:7dd4fbc8f7b4
user: dmg <dmg@...>
date: Wed Jun 06 16:05:46 2007 +0000
description:
2007-06-06 dmg <dmg@...>
* Added support for reading control points.
2007-05-13 dmg <dmg@...>
* scanner.l, parser.y: Changed PT_TOKEN_FLOAT to
PT_TOKEN_NUMBER. Removed PT_TOKEN_INT. Now all numbers are float,
but down-converted to int if necessary (using lroundf). Created a
new token for cropping (PT_TOKEN_CROPPING). It simplifies error messages.
2007-05-03 dmg <dmg@...>
* parser.y (PT_TOKEN_STRING): Fixed spelling mistake in huberEstimator
* tparser.c (panoScriptParse): Fixed spelling mistake in name of parameter
details: http://hugin.hg.sourceforge.net/hgweb/hugin/libpanorama/hgrepo/h/hu/hugin/libpanorama/rev/780e1bef4eb1
changeset: 9:780e1bef4eb1
user: dmg <dmg@...>
date: Thu Jun 07 03:06:05 2007 +0000
description:
2007-06-06 dmg <dmg@...>
* Tparser.c (panoParserDumpImage): Fixed a compilation error that
slip through in my last commit
details: http://hugin.hg.sourceforge.net/hgweb/hugin/libpanorama/hgrepo/h/hu/hugin/libpanorama/rev/f6c1766c61b7
changeset: 10:f6c1766c61b7
user: dmg <dmg@...>
date: Thu Jun 07 03:13:09 2007 +0000
description:
I failed to udpate tparser.c
details: http://hugin.hg.sourceforge.net/hgweb/hugin/libpanorama/hgrepo/h/hu/hugin/libpanorama/rev/64142d59c866
changeset: 11:64142d59c866
user: dmg <dmg@...>
date: Thu Jun 07 03:36:20 2007 +0000
description:
Fixed cmake script. It does not create a library, but it creates the test executable
details: http://hugin.hg.sourceforge.net/hgweb/hugin/libpanorama/hgrepo/h/hu/hugin/libpanorama/rev/82795bc35ed2
changeset: 12:82795bc35ed2
user: dangelo <dangelo@...>
date: Sat Jun 09 13:14:38 2007 +0000
description:
build a library for the parser anyway, this is required for the transform wrapper
details: http://hugin.hg.sourceforge.net/hgweb/hugin/libpanorama/hgrepo/h/hu/hugin/libpanorama/rev/e84de856a968
changeset: 13:e84de856a968
user: dangelo <dangelo@...>
date: Sat Jun 09 13:16:03 2007 +0000
description:
details: http://hugin.hg.sourceforge.net/hgweb/hugin/libpanorama/hgrepo/h/hu/hugin/libpanorama/rev/bae180ab9538
changeset: 14:bae180ab9538
user: dangelo <dangelo@...>
date: Tue Jun 12 12:14:36 2007 +0000
description:
directory for vips operations
details: http://hugin.hg.sourceforge.net/hgweb/hugin/libpanorama/hgrepo/h/hu/hugin/libpanorama/rev/54cb0ddddf64
changeset: 15:54cb0ddddf64
user: dangelo <dangelo@...>
date: Tue Jun 12 12:17:26 2007 +0000
description:
added vips directory
details: http://hugin.hg.sourceforge.net/hgweb/hugin/libpanorama/hgrepo/h/hu/hugin/libpanorama/rev/20583707f6f4
changeset: 16:20583707f6f4
user: dangelo <dangelo@...>
date: Tue Jun 12 12:19:17 2007 +0000
description:
added check for vips
details: http://hugin.hg.sourceforge.net/hgweb/hugin/libpanorama/hgrepo/h/hu/hugin/libpanorama/rev/f48183c5920e
changeset: 17:f48183c5920e
user: shahid_du <shahid_du@...>
date: Thu Jun 14 14:10:57 2007 +0000
description:
Implementation of a simple vips plugin to build transform image.
details: http://hugin.hg.sourceforge.net/hgweb/hugin/libpanorama/hgrepo/h/hu/hugin/libpanorama/rev/c57b842453d7
changeset: 18:c57b842453d7
user: dmg <dmg@...>
date: Thu Jun 14 23:54:17 2007 +0000
description:
2007-06-14 dmg <dmg@...>
* parser.y: Fixed an out-of-bounds error.
* tparserdebug.h, parser.y, tparser.c: added this file.
details: http://hugin.hg.sourceforge.net/hgweb/hugin/libpanorama/hgrepo/h/hu/hugin/libpanorama/rev/9f6c391773c2
changeset: 19:9f6c391773c2
user: dmg <dmg@...>
date: Fri Jun 15 06:11:54 2007 +0000
description:
2007-06-14 dmg <dmg@...>
* tparserdebug.h (DEBUG_2): THe #else had the wrong number of parms.
details: http://hugin.hg.sourceforge.net/hgweb/hugin/libpanorama/hgrepo/h/hu/hugin/libpanorama/rev/575c2a4229b1
changeset: 20:575c2a4229b1
user: dmg <dmg@...>
date: Fri Jun 15 06:15:27 2007 +0000
description:
2007-06-14 dmg <dmg@...>
* tparserdebug.h (DEBUG_2): THe #else had the wrong number of parms.
details: http://hugin.hg.sourceforge.net/hgweb/hugin/libpanorama/hgrepo/h/hu/hugin/libpanorama/rev/5c31c5dfb632
changeset: 21:5c31c5dfb632
user: shahid_du <shahid_du@...>
date: Wed Jun 20 07:34:38 2007 +0000
description:
Deleted old fies for making a new directory structure to keep plugins in seperate directories.
details: http://hugin.hg.sourceforge.net/hgweb/hugin/libpanorama/hgrepo/h/hu/hugin/libpanorama/rev/03ce58beaafb
changeset: 22:03ce58beaafb
user: shahid_du <shahid_du@...>
date: Wed Jun 20 07:39:47 2007 +0000
description:
Added CMakelists.txt, transform and resample plugin in seperate directories.
details: http://hugin.hg.sourceforge.net/hgweb/hugin/libpanorama/hgrepo/h/hu/hugin/libpanorama/rev/db8a3677bf11
changeset: 23:db8a3677bf11
user: shahid_du <shahid_du@...>
date: Fri Jun 22 16:53:48 2007 +0000
description:
Added test directory and added the test PIO resample program.
details: http://hugin.hg.sourceforge.net/hgweb/hugin/libpanorama/hgrepo/h/hu/hugin/libpanorama/rev/b04161278b48
changeset: 24:b04161278b48
user: shahid_du <shahid_du@...>
date: Sat Jun 23 05:38:04 2007 +0000
description:
Corrected some errors in testResamplePIO.c
details: http://hugin.hg.sourceforge.net/hgweb/hugin/libpanorama/hgrepo/h/hu/hugin/libpanorama/rev/e1d16c5fa7eb
changeset: 25:e1d16c5fa7eb
user: shahid_du <shahid_du@...>
date: Sun Jun 24 08:02:57 2007 +0000
description:
Modified programming style in testResamplePIO.c and also added Changelog.
details: http://hugin.hg.sourceforge.net/hgweb/hugin/libpanorama/hgrepo/h/hu/hugin/libpanorama/rev/a1186a806ec3
changeset: 26:a1186a806ec3
user: shahid_du <shahid_du@...>
date: Sun Jun 24 08:05:55 2007 +0000
description:
Changed the resample plugin from wIO to PIO.
details: http://hugin.hg.sourceforge.net/hgweb/hugin/libpanorama/hgrepo/h/hu/hugin/libpanorama/rev/47b9fadf7e86
changeset: 27:47b9fadf7e86
user: shahid_du <shahid_du@...>
date: Tue Jun 26 18:57:31 2007 +0000
description:
Added transmap directory to contain a test program to create transformed and resampled image. Modified the plugins a bit to make it suitable to apply in transmap.
details: http://hugin.hg.sourceforge.net/hgweb/hugin/libpanorama/hgrepo/h/hu/hugin/libpanorama/rev/7913d34e9ae0
changeset: 28:7913d34e9ae0
user: dangelo <dangelo@...>
date: Wed Jun 27 06:46:40 2007 +0000
description:
Bugfix: destination projection type was not converted properly
details: http://hugin.hg.sourceforge.net/hgweb/hugin/libpanorama/hgrepo/h/hu/hugin/libpanorama/rev/02a0eb4e3e88
changeset: 29:02a0eb4e3e88
user: shahid_du <shahid_du@...>
date: Wed Jun 27 14:23:40 2007 +0000
description:
Added billinear interpolation skeleton to resample plugin, need to make it work. Also cleaned up the CMakeLists.txt of transmap.
details: http://hugin.hg.sourceforge.net/hgweb/hugin/libpanorama/hgrepo/h/hu/hugin/libpanorama/rev/d1eed7551e59
changeset: 30:d1eed7551e59
user: dangelo <dangelo@...>
date: Wed Jun 27 20:44:20 2007 +0000
description:
fixed cmake build system to properly setup compiler and linker flags for VIPS
details: http://hugin.hg.sourceforge.net/hgweb/hugin/libpanorama/hgrepo/h/hu/hugin/libpanorama/rev/6bcdcda12843
changeset: 31:6bcdcda12843
user: dmg <dmg@...>
date: Thu Jun 28 00:10:53 2007 +0000
description:
2007-06-27 dmg <dmg@...>
* parser.y: Improved error handling in case of unrecognized
lines. Previously it was stopping at the first line it did not
recognized, but returned no error.
* parser.y, tparser.c, tparser.h (struct): Added parameters
outputPixelType and photometricHuberSigma. Added feather size (u)
in images lines
* scanner.l: Added token for #-hugin variables.
details: http://hugin.hg.sourceforge.net/hgweb/hugin/libpanorama/hgrepo/h/hu/hugin/libpanorama/rev/3c303d9d0ddb
changeset: 32:3c303d9d0ddb
user: dmg <dmg@...>
date: Thu Jun 28 00:17:18 2007 +0000
description:
added a file for todo tasks
details: http://hugin.hg.sourceforge.net/hgweb/hugin/libpanorama/hgrepo/h/hu/hugin/libpanorama/rev/353d50736a40
changeset: 33:353d50736a40
user: dmg <dmg@...>
date: Thu Jun 28 02:47:40 2007 +0000
description:
removed debugging messages
details: http://hugin.hg.sourceforge.net/hgweb/hugin/libpanorama/hgrepo/h/hu/hugin/libpanorama/rev/e763fd2f2c92
changeset: 34:e763fd2f2c92
user: shahid_du <shahid_du@...>
date: Thu Jun 28 06:30:25 2007 +0000
description:
Added interpolation files which was missing in last commit.
details: http://hugin.hg.sourceforge.net/hgweb/hugin/libpanorama/hgrepo/h/hu/hugin/libpanorama/rev/4f056b927b3f
changeset: 35:4f056b927b3f
user: shahid_du <shahid_du@...>
date: Thu Jun 28 06:33:54 2007 +0000
description:
Deleted interpolation.h~ backup file.
details: http://hugin.hg.sourceforge.net/hgweb/hugin/libpanorama/hgrepo/h/hu/hugin/libpanorama/rev/473f173cc3c7
changeset: 36:473f173cc3c7
user: dangelo <dangelo@...>
date: Thu Jun 28 08:25:48 2007 +0000
description:
updated CMake build system to install the parser and panotoolswrapper libraries
details: http://hugin.hg.sourceforge.net/hgweb/hugin/libpanorama/hgrepo/h/hu/hugin/libpanorama/rev/c18ccdd85a65
changeset: 37:c18ccdd85a65
user: shahid_du <shahid_du@...>
date: Thu Jun 28 11:13:56 2007 +0000
description:
Added billinear interpolation. Fixed some silly bugs in transmap.
details: http://hugin.hg.sourceforge.net/hgweb/hugin/libpanorama/hgrepo/h/hu/hugin/libpanorama/rev/672fd65daab8
changeset: 38:672fd65daab8
user: shahid_du <shahid_du@...>
date: Thu Jun 28 12:00:04 2007 +0000
description:
Added billinear interpolation functions missing in transmap directory.
details: http://hugin.hg.sourceforge.net/hgweb/hugin/libpanorama/hgrepo/h/hu/hugin/libpanorama/rev/50d38e8c53ab
changeset: 39:50d38e8c53ab
user: shahid_du <shahid_du@...>
date: Thu Jun 28 13:13:37 2007 +0000
description:
Moved all vips sources to vips directory.
details: http://hugin.hg.sourceforge.net/hgweb/hugin/libpanorama/hgrepo/h/hu/hugin/libpanorama/rev/1b5983bd504e
changeset: 40:1b5983bd504e
user: dmg <dmg@...>
date: Thu Jun 28 22:16:45 2007 +0000
description:
007-06-28 dmg <dmg@...>
* parser.y, tparser.c, tparser.h: Implemented R variable in p-line
* parser.y, tparser.c, tparser.h, scanner.l: Implemented Hugin
autoCenterCrop and cropFactor in i-lines.
details: http://hugin.hg.sourceforge.net/hgweb/hugin/libpanorama/hgrepo/h/hu/hugin/libpanorama/rev/d6980f7857b5
changeset: 41:d6980f7857b5
user: dmg <dmg@...>
date: Thu Jun 28 22:41:55 2007 +0000
description:
2007-06-28 dmg <dmg@...>
* tparser.h, tparser.h, tparser.c: Added all the variables needed
by Hugin, renamed some of them.
details: http://hugin.hg.sourceforge.net/hgweb/hugin/libpanorama/hgrepo/h/hu/hugin/libpanorama/rev/4c9a1410220f
changeset: 42:4c9a1410220f
user: dmg <dmg@...>
date: Fri Jun 29 06:09:20 2007 +0000
description:
2007-06-28 dmg <dmg@...>
* parser.y, tparser.c, tparser.h, scanner.l: I think I finished
implementing all the hugin specific parameters.
details: http://hugin.hg.sourceforge.net/hgweb/hugin/libpanorama/hgrepo/h/hu/hugin/libpanorama/rev/61a00424ce93
changeset: 43:61a00424ce93
user: shahid_du <shahid_du@...>
date: Fri Jun 29 13:54:29 2007 +0000
description:
Fixed some plugin input. Added interpolation type input in resample
details: http://hugin.hg.sourceforge.net/hgweb/hugin/libpanorama/hgrepo/h/hu/hugin/libpanorama/rev/5b618a874273
changeset: 44:5b618a874273
user: shahid_du <shahid_du@...>
date: Sun Jul 01 07:37:57 2007 +0000
description:
Added development version of mask image ouput and bicubic interpolation.
details: http://hugin.hg.sourceforge.net/hgweb/hugin/libpanorama/hgrepo/h/hu/hugin/libpanorama/rev/a2937906b7c9
changeset: 45:a2937906b7c9
user: shahid_du <shahid_du@...>
date: Tue Jul 03 10:52:43 2007 +0000
description:
Committed some minor improvement in vips sources directory.
details: http://hugin.hg.sourceforge.net/hgweb/hugin/libpanorama/hgrepo/h/hu/hugin/libpanorama/rev/4dd149c3ad52
changeset: 46:4dd149c3ad52
user: shahid_du <shahid_du@...>
date: Wed Jul 04 05:17:36 2007 +0000
description:
Committed fixed mask image generation and bicubic interpolation.
details: http://hugin.hg.sourceforge.net/hgweb/hugin/libpanorama/hgrepo/h/hu/hugin/libpanorama/rev/c853f7e0955a
changeset: 47:c853f7e0955a
user: shahid_du <shahid_du@...>
date: Thu Jul 05 06:03:11 2007 +0000
description:
Made the panoScirptParse argument TRUE in transform operation.
details: http://hugin.hg.sourceforge.net/hgweb/hugin/libpanorama/hgrepo/h/hu/hugin/libpanorama/rev/6986bfbf4efc
changeset: 48:6986bfbf4efc
user: shahid_du <shahid_du@...>
date: Thu Jul 05 11:30:47 2007 +0000
description:
Fixed the interpolation method to work with expanded image by im_embed.
details: http://hugin.hg.sourceforge.net/hgweb/hugin/libpanorama/hgrepo/h/hu/hugin/libpanorama/rev/4fc26a137a1a
changeset: 49:4fc26a137a1a
user: shahid_du <shahid_du@...>
date: Sun Jul 08 10:24:10 2007 +0000
description:
Added input image mask generation and checking.
details: http://hugin.hg.sourceforge.net/hgweb/hugin/libpanorama/hgrepo/h/hu/hugin/libpanorama/rev/d4f17a38f98e
changeset: 50:d4f17a38f98e
user: shahid_du <shahid_du@...>
date: Sun Jul 08 18:03:45 2007 +0000
description:
Added missing files maskgen.c and maskgen.h.
details: http://hugin.hg.sourceforge.net/hgweb/hugin/libpanorama/hgrepo/h/hu/hugin/libpanorama/rev/aea80ee5a614
changeset: 51:aea80ee5a614
user: shahid_du <shahid_du@...>
date: Wed Jul 11 07:06:00 2007 +0000
description:
Fixed interpolation and spot problem along with some modification.
details: http://hugin.hg.sourceforge.net/hgweb/hugin/libpanorama/hgrepo/h/hu/hugin/libpanorama/rev/a42ec9c8ac63
changeset: 52:a42ec9c8ac63
user: dmg <dmg@...>
date: Mon Aug 11 05:22:51 2008 +0000
description:
008-08-10 dmg <dmg@...>
* scanner.l, parser.y: Finally! properly handle end-of-input.
* CMakeLists.txt: Added GCC declaration for GCC compilation of
lround. It might not work on other compilers. This needs ot be fixed.
* tparser.h: Added declarations to remove warning
details: http://hugin.hg.sourceforge.net/hgweb/hugin/libpanorama/hgrepo/h/hu/hugin/libpanorama/rev/e68e4f22bd1e
changeset: 53:e68e4f22bd1e
user: dmg <dmg@...>
date: Mon Aug 11 05:35:57 2008 +0000
description:
2008-08-10 dmg <dmg@...>
* CMakeLists.txt: Changed name of library to tparser, added
tparser.h as a file to instal
details: http://hugin.hg.sourceforge.net/hgweb/hugin/libpanorama/hgrepo/h/hu/hugin/libpanorama/rev/7c5f0a3fa0fe
changeset: 54:7c5f0a3fa0fe
user: dmg <dmg@...>
date: Tue Aug 26 05:44:10 2008 +0000
description:
Updated the parser to support setting defaults
diffstat:
CMakeLists.txt | 42 +
CMakeModules/FindBISON.cmake | 179 ++++++
CMakeModules/FindFLEX.cmake | 143 +++++
CMakeModules/FindPkgConfig.cmake | 360 +++++++++++++
src/CMakeLists.txt | 5 +
src/panotools-wrappers/CMakeLists.txt | 16 +
src/panotools-wrappers/ChangeLog | 16 +
src/panotools-wrappers/README | 15 +
src/panotools-wrappers/pttransform.c | 273 ++++++++++
src/panotools-wrappers/pttransform.h | 115 ++++
src/panotools-wrappers/test.pto | 20 +
src/panotools-wrappers/testtransform.c | 73 ++
src/parser/AUTHORS | 1 +
src/parser/CMakeLists.txt | 34 +
src/parser/COPYING | 340 +++++++++++++
src/parser/ChangeLog | 131 +++++
src/parser/Makefile.am | 26 +
src/parser/README.txt | 42 +
src/parser/TODO | 23 +
src/parser/parser.y | 724 +++++++++++++++++++++++++++
src/parser/scanner.l | 310 +++++++++++
src/parser/testparser.c | 70 ++
src/parser/tparser.c | 854 +++++++++++++++++++++++++++++++++
src/parser/tparser.h | 213 ++++++++
src/parser/tparserdebug.h | 38 +
src/parser/tparserprivate.h | 41 +
src/projections/AUTHORS | 1 +
src/projections/COPYING | 340 +++++++++++++
src/projections/README.txt | 46 +
src/projections/TODO | 31 +
src/projections/projazimuthals.c | 611 +++++++++++++++++++++++
src/projections/projazimuthals.h | 90 +++
src/projections/projcylindricals.c | 513 +++++++++++++++++++
src/projections/projcylindricals.h | 91 +++
src/projections/projections.c | 47 +
src/projections/projections.h | 90 +++
src/vips/CMakeLists.txt | 41 +
src/vips/ChangeLog | 73 ++
src/vips/README | 1 +
src/vips/interpolation.c | 116 ++++
src/vips/interpolation.h | 16 +
src/vips/maskgen.c | 67 ++
src/vips/maskgen.h | 27 +
src/vips/plug.c | 99 +++
src/vips/resample.c | 304 +++++++++++
src/vips/resample.h | 11 +
src/vips/test/ChangeLog | 11 +
src/vips/test/testResamplePIO.c | 194 +++++++
src/vips/transform.c | 134 +++++
src/vips/transform.h | 15 +
src/vips/transmap.c | 105 ++++
51 files changed, 7178 insertions(+), 0 deletions(-)
diffs (7382 lines):
diff -r 000000000000 -r 7c5f0a3fa0fe CMakeLists.txt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/CMakeLists.txt Tue Aug 26 05:44:10 2008 +0000
@@ -0,0 +1,42 @@
+set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMakeModules )
+
+project(libpanorama)
+
+FIND_PACKAGE(BISON REQUIRED)
+FIND_PACKAGE(FLEX REQUIRED)
+FIND_PACKAGE(PkgConfig)
+
+
+# macro to convert a CMAKE list to a string
+MACRO(LIST2STRING alist astring)
+ FOREACH(elem ${${alist}})
+ SET(${astring} "${${astring}} ${elem}")
+ ENDFOREACH(elem)
+ENDMACRO(LIST2STRING)
+
+# check for VIPS
+pkg_check_modules(VIPS vips-7.12)
+
+# convert CFLAGS_OTHER and LDFLAGS_OTHER to an ordinary string
+LIST2STRING(VIPS_CFLAGS_OTHER VIPS_CFLAGS_OTHER_STRING)
+LIST2STRING(VIPS_LDFLAGS_OTHER VIPS_LDFLAGS_OTHER_STRING)
+
+# set include and library directories to include all libraries
+# required by VIPS
+link_directories( ${VIPS_LIBRARY_DIRS} )
+include_directories( ${VIPS_INCLUDE_DIRS} )
+
+# always compile with -Wall
+IF(CMAKE_COMPILER_IS_GNUCC)
+ ADD_DEFINITIONS("-Wall")
+ENDIF(CMAKE_COMPILER_IS_GNUCC)
+
+#MESSAGE("VIPS_CFLAGS: ${VIPS_CFLAGS}")
+#MESSAGE("VIPS_CFLAGS_OTHER_STRING: ${VIPS_CFLAGS_OTHER_STRING}")
+#MESSAGE("VIPS_INCLUDE_DIRS: ${VIPS_INCLUDE_DIRS}")
+#MESSAGE("VIPS_LIBRARIES: ${VIPS_LIBRARIES}")
+#MESSAGE("VIPS_LIBRARY_DIRS: ${VIPS_LIBRARY_DIRS}")
+#MESSAGE("VIPS_LDFLAGS: ${VIPS_LDFLAGS}")
+#MESSAGE("VIPS_LDFLAGS_OTHER_STRING: ${VIPS_LDFLAGS_OTHER_STRING}")
+
+add_subdirectory(src)
diff -r 000000000000 -r 7c5f0a3fa0fe CMakeModules/FindBISON.cmake
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/CMakeModules/FindBISON.cmake Tue Aug 26 05:44:10 2008 +0000
@@ -0,0 +1,179 @@
+# - Find bison executable and provides macros to generate custom build rules
+# The module defined the following variables:
+# BISON_EXECUTABLE - path to the bison program
+# BISON_VERSION - version of bison
+# BISON_FOUND - true if the program was found
+# If bison is found, the module defines the macros:
+# BISON_TARGET(<Name> <YaccInput> <CodeOutput> [VERBOSE <file>]
+# [COMPILE_FLAGS <string>])
+# which will create a custom rule to generate a parser. <YaccInput> is
+# the path to a yacc file. <CodeOutput> is the name of the source file
+# generated by bison. A header file is also be generated, and contains
+# the token list. If COMPILE_FLAGS option is specified, the next
+# parameter is added in the bison command line. if VERBOSE option is
+# specified, <file> is created and contains verbose descriptions of the
+# grammar and parser. The macro defines a set of variables:
+# BISON_${Name}_DEFINED - true is the macro ran successfully
+# BISON_${Name}_INPUT - The input source file, an alias for <YaccInput>
+# BISON_${Name}_OUTPUT_SOURCE - The source file generated by bison
+# BISON_${Name}_OUTPUT_HEADER - The header file generated by bison
+# BISON_${Name}_OUTPUTS - The sources files generated by bison
+# BISON_${Name}_COMPILE_FLAGS - Options used in the bison command line
+#
+# Example:
+# FIND_PACKAGE(BISON)
+# BISON_TARGET(MyParser parser.y ${PROJECT_BINARY_DIR}/parser.cpp)
+# ADD_EXECUTABLE(Foo main.cpp ${BISON_MyParser_OUTPUTS})
+#
+# changes by Pablo d'Angelo:
+# Tried to make it work with cmake 2.2
+# Probably broke something, see the uncommented LIST commands below
+# For now, used explicit rules in the respective CMakeList.txt instead
+# for BISON_TARGET and FLEX_TARGET
+
+
+# Copyright (c) 2006, Tristan Carel
+# All rights reserved.
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# * Neither the name of the University of California, Berkeley nor the
+# names of its contributors may be used to endorse or promote products
+# derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
+# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+# $Id:: FindBISON.cmake 3 2006-11-03 02:42:02Z ken $
+
+SET(BISON_FOUND FALSE)
+
+FIND_PROGRAM(BISON_EXECUTABLE bison DOC "path to the bison executable")
+MARK_AS_ADVANCED(BISON_EXECUTABLE)
+
+IF(BISON_EXECUTABLE)
+ SET(BISON_FOUND TRUE)
+
+ EXEC_PROGRAM(${BISON_EXECUTABLE}
+ ARGS "--version"
+ OUTPUT_VARIABLE BISON_version_output
+ ERROR_VARIABLE BISON_version_error
+ RETURN_VALUE BISON_version_result)
+# EXECUTE_PROCESS(COMMAND ${BISON_EXECUTABLE} --version
+# OUTPUT_VARIABLE BISON_version_output
+# ERROR_VARIABLE BISON_version_error
+# RESULT_VARIABLE BISON_version_result
+# OUTPUT_STRIP_TRAILING_WHITESPACE)
+ IF(NOT ${BISON_version_result} EQUAL 0)
+ MESSAGE(SEND_ERROR "Command \"${BISON_EXECUTABLE} --version\" failed with output:\n${BISON_version_output}")
+ ELSE(NOT ${BISON_version_result} EQUAL 0)
+ STRING(REGEX REPLACE "^bison \\(GNU Bison\\) ([^\n]+)\n.*" "\\1"
+ BISON_VERSION "${BISON_version_output}")
+ ENDIF(NOT ${BISON_version_result} EQUAL 0)
+
+ # internal macro
+ MACRO(BISON_TARGET_option_verbose Name BisonOutput filename)
+ SET(BISON_TARGET_cmdopt "$(BISON_TARGET_cmdopt)" "--verbose")
+# LIST(APPEND BISON_TARGET_cmdopt "--verbose")
+ GET_FILENAME_COMPONENT(BISON_TARGET_output_path "${BisonOutput}" PATH)
+ GET_FILENAME_COMPONENT(BISON_TARGET_output_name "${BisonOutput}" NAME_WE)
+ ADD_CUSTOM_COMMAND(OUTPUT ${filename}
+ COMMAND ${CMAKE_COMMAND} -E copy
+ "${BISON_TARGET_output_path}/${BISON_TARGET_output_name}.output"
+ "${filename}"
+ DEPENDS
+ "${BISON_TARGET_output_path}/${BISON_TARGET_output_name}.output"
+ COMMENT "[BISON][${Name}] Copying bison verbose table to ${filename}"
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
+ SET(BISON_${Name}_VERBOSE_FILE ${filename})
+ #LIST(APPEND BISON_TARGET_extraoutputs
+ # "${BISON_TARGET_output_path}/${BISON_TARGET_output_name}.output")
+ SET(BISON_TARGET_extraoutputs "${BISON_TARGET_extraoutputs}"
+ "${BISON_TARGET_output_path}/${BISON_TARGET_output_name}.output")
+ ENDMACRO(BISON_TARGET_option_verbose)
+
+ # internal macro
+ MACRO(BISON_TARGET_option_extraopts Options)
+ SET(BISON_TARGET_extraopts "${Options}")
+ SEPARATE_ARGUMENTS(BISON_TARGET_extraopts)
+ SET(BISON_TARGET_cmdopt ${BISON_TARGET_cmdopt} ${BISON_TARGET_extraopts})
+ #LIST(APPEND BISON_TARGET_cmdopt ${BISON_TARGET_extraopts})
+ ENDMACRO(BISON_TARGET_option_extraopts)
+
+ MACRO(BISON_TARGET Name BisonInput BisonOutput)
+ SET(BISON_TARGET_output_header "")
+ SET(BISON_TARGET_command_opt "")
+ SET(BISON_TARGET_outputs "${BisonOutput}")
+ IF(NOT ${ARGC} EQUAL 3 AND NOT ${ARGC} EQUAL 5 AND NOT ${ARGC} EQUAL 7)
+ MESSAGE(SEND_ERROR "Usage")
+ ELSE(NOT ${ARGC} EQUAL 3 AND NOT ${ARGC} EQUAL 5 AND NOT ${ARGC} EQUAL 7)
+ # Parsing parameters
+ IF(${ARGC} GREATER 5 OR ${ARGC} EQUAL 5)
+ IF("${ARGV3}" STREQUAL "VERBOSE")
+ BISON_TARGET_option_verbose(${Name} ${BisonOutput} "${ARGV4}")
+ ENDIF("${ARGV3}" STREQUAL "VERBOSE")
+ IF("${ARGV3}" STREQUAL "COMPILE_FLAGS")
+ BISON_TARGET_option_extraopts("${ARGV4}")
+ ENDIF("${ARGV3}" STREQUAL "COMPILE_FLAGS")
+ ENDIF(${ARGC} GREATER 5 OR ${ARGC} EQUAL 5)
+ IF(${ARGC} EQUAL 7)
+ IF("${ARGV5}" STREQUAL "VERBOSE")
+ BISON_TARGET_option_verbose(${Name} ${BisonOutput} "${ARGV6}")
+ ENDIF("${ARGV5}" STREQUAL "VERBOSE")
+ IF("${ARGV5}" STREQUAL "COMPILE_FLAGS")
+ BISON_TARGET_option_extraopts("${ARGV6}")
+ ENDIF("${ARGV5}" STREQUAL "COMPILE_FLAGS")
+ ENDIF(${ARGC} EQUAL 7)
+
+ # Header's name generated by bison (see option -d)
+ SET(BISON_TARGET_cmdopt ${BISON_TARGET_cmdopt} "-d")
+ #LIST(APPEND BISON_TARGET_cmdopt "-d")
+ STRING(REGEX REPLACE "^(.*)\\.c([^.]*)$" "\\1.h\\2"
+ BISON_${Name}_OUTPUT_HEADER "${ARGV2}")
+ #LIST(APPEND BISON_TARGET_outputs "${BISON_${Name}_OUTPUT_HEADER}")
+ SET(BISON_TARGET_outputs "${BISON_TARGET_outputs}" "${BISON_${Name}_OUTPUT_HEADER}")
+
+ ADD_CUSTOM_COMMAND(OUTPUT ${BISON_TARGET_outputs}
+ ${BISON_TARGET_extraoutputs}
+ COMMAND ${BISON_EXECUTABLE} ${BISON_TARGET_cmdopt} -o ${ARGV2} ${ARGV1}
+ DEPENDS ${ARGV1}
+ COMMENT "[BISON][${Name}] Building parser with bison ${BISON_VERSION}"
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
+
+ # define target variables
+ SET(BISON_${Name}_DEFINED TRUE)
+ SET(BISON_${Name}_INPUT ${ARGV1})
+ SET(BISON_${Name}_OUTPUTS ${BISON_TARGET_outputs})
+ SET(BISON_${Name}_COMPILE_FLAGS ${BISON_TARGET_cmdopt})
+ SET(BISON_${Name}_OUTPUT_SOURCE "${BisonOutput}")
+
+ ENDIF(NOT ${ARGC} EQUAL 3 AND NOT ${ARGC} EQUAL 5 AND NOT ${ARGC} EQUAL 7)
+ ENDMACRO(BISON_TARGET)
+
+ENDIF(BISON_EXECUTABLE)
+
+
+IF(NOT BISON_FOUND)
+ IF(NOT BISON_FIND_QUIETLY)
+ MESSAGE(STATUS "BISON was not found.")
+ ELSE(NOT BISON_FIND_QUIETLY)
+ IF(BISON_FIND_REQUIRED)
+ MESSAGE(FATAL_ERROR "BISON was not found.")
+ ENDIF(BISON_FIND_REQUIRED)
+ ENDIF(NOT BISON_FIND_QUIETLY)
+ENDIF(NOT BISON_FOUND)
+
+# FindBISON.cmake ends here
diff -r 000000000000 -r 7c5f0a3fa0fe CMakeModules/FindFLEX.cmake
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/CMakeModules/FindFLEX.cmake Tue Aug 26 05:44:10 2008 +0000
@@ -0,0 +1,143 @@
+# - Find flex executable and provides a macro to generate custom build rules
+# The module defines the following variables:
+# FLEX_FOUND - true is flex executable is found
+# FLEX_VERSION - the version of flex
+# If flex is found on the system, the module provides the macro:
+# FLEX_TARGET(Name FlexInput FlexOutput [COMPILE_FLAGS <string>])
+# which creates a custom command to generate the <FlexOutput> file from
+# the <FlexInput> file. If COMPILE_FLAGS option is specified, the next
+# parameter is added to the flex command line. Name is an alias used to
+# get details of this custom command. Indeed the macro defines the
+# following variables:
+# FLEX_${Name}_DEFINED - true is the macro ran successfully
+# FLEX_${Name}_OUTPUTS - the source file generated by the custom rule, an
+# alias for FlexOutput
+# FLEX_${Name}_INPUT - the flex source file, an alias for ${FlexInput}
+#
+# Flex scanners oftenly use tokens defined by Bison: the code generated
+# by Flex depends of the header generated by Bison. This module also
+# defines a macro:
+# ADD_FLEX_BISON_DEPENDENCY(FlexTarget BisonTarget)
+# which adds the required dependency between a scanner and a parser
+# where <FlexTarget> and <BisonTarget> are the first parameters of
+# respectively FLEX_TARGET and BISON_TARGET macros.
+#
+# Example:
+# FIND_PACKAGE(BISON)
+# FIND_PACKAGE(FLEX)
+# BISON_TARGET(MyParser parser.y ${PROJECT_BINARY_DIR}/parser.cpp
+# FLEX_TARGET(MyScanner lexer.l ${PROJECT_BINARY_DIR}/lexer.cpp)
+# ADD_FLEX_BISON_DEPENDENCY(MyScanner MyParser)
+#
+# changes by Pablo d'Angelo:
+# Tried to make it work with cmake 2.2
+# Probably broke something, see the uncommented LIST commands below
+# For now, used explicit rules in the respective CMakeList.txt instead
+# for BISON_TARGET and FLEX_TARGET
+
+# Copyright (c) 2006, Tristan Carel
+# All rights reserved.
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# * Neither the name of the University of California, Berkeley nor the
+# names of its contributors may be used to endorse or promote products
+# derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
+# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+# $Id:: FindFLEX.cmake 3 2006-11-03 02:42:02Z ken $
+
+SET(FLEX_FOUND FALSE)
+
+FIND_PROGRAM(FLEX_EXECUTABLE flex DOC "path to the flex executable")
+MARK_AS_ADVANCED(FLEX_EXECUTABLE)
+
+FIND_LIBRARY(FL_LIBRARY NAMES fl
+ PATHS /usr/lib DOC "path to the fl library")
+SET(FLEX_LIBRARIES ${FL_LIBRARY})
+
+IF(FLEX_EXECUTABLE)
+ SET(FLEX_FOUND TRUE)
+
+ EXEC_PROGRAM(${FLEX_EXECUTABLE}
+ ARGS "--version"
+ OUTPUT_VARIABLE FLEX_version_output
+ RETURN_VALUE FLEX_version_result)
+# EXECUTE_PROCESS(COMMAND ${FLEX_EXECUTABLE} --version
+# OUTPUT_VARIABLE FLEX_version_output
+# ERROR_VARIABLE FLEX_version_error
+# RESULT_VARIABLE FLEX_version_result
+# OUTPUT_STRIP_TRAILING_WHITESPACE)
+ IF(NOT ${FLEX_version_result} EQUAL 0)
+ MESSAGE(SEND_ERROR "Command \"${FLEX_EXECUTABLE} --version\" failed with output:\n${FLEX_version_error}")
+ ELSE(NOT ${FLEX_version_result} EQUAL 0)
+ STRING(REGEX REPLACE "^flex (.*)$" "\\1"
+ FLEX_VERSION "${FLEX_version_output}")
+ ENDIF(NOT ${FLEX_version_result} EQUAL 0)
+
+ MACRO(FLEX_TARGET Name Input Output)
+ SET(FLEX_TARGET_usage "FLEX_TARGET(<Name> <Input> <Output> [COMPILE_FLAGS <string>]")
+ IF(${ARGC} GREATER 3)
+ IF(${ARGC} EQUAL 5)
+ IF("${ARGV3}" STREQUAL "COMPILE_FLAGS")
+ SET(FLEX_EXECUTABLE_opts "${ARGV4}")
+ SEPARATE_ARGUMENTS(FLEX_EXECUTABLE_opts)
+ ELSE("${ARGV3}" STREQUAL "COMPILE_FLAGS")
+ MESSAGE(SEND_ERROR ${FLEX_TARGET_usage})
+ ENDIF("${ARGV3}" STREQUAL "COMPILE_FLAGS")
+ ELSE(${ARGC} EQUAL 5)
+ MESSAGE(SEND_ERROR ${FLEX_TARGET_usage})
+ ENDIF(${ARGC} EQUAL 5)
+ ENDIF(${ARGC} GREATER 3)
+ ADD_CUSTOM_COMMAND(OUTPUT ${Output}
+ COMMAND ${FLEX_EXECUTABLE} ${FLEX_EXECUTABLE_opts} -o${Output} ${Input}
+ DEPENDS ${Input}
+ COMMENT "[FLEX][${Name}] Building scanner with flex ${FLEX_VERSION}"
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
+
+ SET(FLEX_${Name}_DEFINED TRUE)
+ SET(FLEX_${Name}_OUTPUTS ${Output})
+ SET(FLEX_${Name}_INPUT ${Input})
+ SET(FLEX_${Name}_COMPILE_FLAGS ${FLEX_EXECUTABLE_opts})
+ ENDMACRO(FLEX_TARGET)
+
+ MACRO(ADD_FLEX_BISON_DEPENDENCY FlexTarget BisonTarget)
+ IF(NOT FLEX_${FlexTarget}_TARGET)
+ MESSAGE(SEND_ERROR "Flex target `${FlexTarget}' does not exists.")
+ ENDIF(NOT FLEX_${FlexTarget}_TARGET)
+ IF(NOT BISON_${BisonTarget}_TARGET)
+ MESSAGE(SEND_ERROR "Bison target `${BisonTarget}' does not exists.")
+ ENDIF(NOT BISON_${BisonTarget}_TARGET)
+
+ SET_SOURCE_FILES_PROPERTIES(${FLEX_${FlexTarget}_OUTPUT}
+ PROPERTIES OBJECT_DEPENDS ${BISON_${BisonTarget}_OUTPUT_HEADER})
+ ENDMACRO(ADD_FLEX_BISON_DEPENDENCY)
+
+ENDIF(FLEX_EXECUTABLE)
+
+IF(NOT FLEX_FOUND)
+ IF(NOT FLEX_FIND_QUIETLY)
+ MESSAGE(STATUS "FLEX was not found.")
+ ELSE(NOT FLEX_FIND_QUIETLY)
+ IF(FLEX_FIND_REQUIRED)
+ MESSAGE(FATAL_ERROR "FLEX was not found.")
+ ENDIF(FLEX_FIND_REQUIRED)
+ ENDIF(NOT FLEX_FIND_QUIETLY)
+ENDIF(NOT FLEX_FOUND)
+
+# FindFLEX.cmake ends here
diff -r 000000000000 -r 7c5f0a3fa0fe CMakeModules/FindPkgConfig.cmake
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/CMakeModules/FindPkgConfig.cmake Tue Aug 26 05:44:10 2008 +0000
@@ -0,0 +1,360 @@
+# - a pkg-config module for CMake
+#
+# Usage:
+# pkg_check_modules(<PREFIX> [REQUIRED] <MODULE> [<MODULE>]*)
+# checks for all the given modules
+#
+# pkg_search_module(<PREFIX> [REQUIRED] <MODULE> [<MODULE>]*)
+# checks for given modules and uses the first working one
+#
+# When the 'REQUIRED' argument was set, macros will fail with an error
+# when module(s) could not be found
+#
+# It sets the following variables:
+# PKG_CONFIG_FOUND ... true iff pkg-config works on the system
+# PKG_CONFIG_EXECUTABLE ... pathname of the pkg-config program
+# <PREFIX>_FOUND ... set to 1 iff module(s) exist
+#
+# For the following variables two sets of values exist; first one is the
+# common one and has the given PREFIX. The second set contains flags
+# which are given out when pkgconfig was called with the '--static'
+# option.
+# <XPREFIX>_LIBRARIES ... only the libraries (w/o the '-l')
+# <XPREFIX>_LIBRARY_DIRS ... the paths of the libraries (w/o the '-L')
+# <XPREFIX>_LDFLAGS ... all required linker flags
+# <XPREFIX>_LDFLAGS_OTHERS ... all other linker flags
+# <XPREFIX>_INCLUDE_DIRS ... the '-I' preprocessor flags (w/o the '-I')
+# <XPREFIX>_CFLAGS ... all required cflags
+# <XPREFIX>_CFLAGS_OTHERS ... the other compiler flags
+#
+# <XPREFIX> = <PREFIX> for common case
+# <XPREFIX> = <PREFIX>_STATIC for static linking
+#
+# There are some special variables whose prefix depends on the count
+# of given modules. When there is only one module, <PREFIX> stays
+# unchanged. When there are multiple modules, the prefix will be
+# changed to <PREFIX>_<MODNAME>:
+# <XPREFIX>_VERSION ... version of the module
+# <XPREFIX>_PREFIX ... prefix-directory of the module
+# <XPREFIX>_INCLUDEDIR ... include-dir of the module
+# <XPREFIX>_LIBDIR ... lib-dir of the module
+#
+# <XPREFIX> = <PREFIX> when |MODULES| == 1, else
+# <XPREFIX> = <PREFIX>_<MODNAME>
+#
+# A <MODULE> parameter can have the following formats:
+# {MODNAME} ... matches any version
+# {MODNAME}>={VERSION} ... at least version <VERSION> is required
+# {MODNAME}={VERSION} ... exactly version <VERSION> is required
+# {MODNAME}<={VERSION} ... modules must not be newer than <VERSION>
+#
+# Examples
+# pkg_check_modules (GLIB2 glib-2.0)
+#
+# pkg_check_modules (GLIB2 glib-2.0>=2.10)
+# requires at least version 2.10 of glib2 and defines e.g.
+# GLIB2_VERSION=2.10.3
+#
+# pkg_check_modules (FOO glib-2.0>=2.10 gtk+-2.0)
+# requires both glib2 and gtk2, and defines e.g.
+# FOO_glib-2.0_VERSION=2.10.3
+# FOO_gtk+-2.0_VERSION=2.8.20
+#
+# pkg_check_modules (XRENDER REQUIRED xrender)
+# defines e.g.:
+# XRENDER_LIBRARIES=Xrender;X11
+# XRENDER_STATIC_LIBRARIES=Xrender;X11;pthread;Xau;Xdmcp
+#
+# pkg_search_module (BAR libxml-2.0 libxml2 libxml>=2)
+
+
+# Copyright (C) 2006 Enrico Scholz <enrico.scholz@...>
+#
+# Redistribution and use, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+# 1. Redistributions must retain the above copyright notice, this
+# list of conditions and the following disclaimer.
+# 2. The name of the author may not be used to endorse or promote
+# products derived from this software without specific prior
+# written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+### Common stuff ####
+set(PKG_CONFIG_VERSION 1)
+set(PKG_CONFIG_FOUND 0)
+
+find_program(PKG_CONFIG_EXECUTABLE NAMES pkg-config DOC "pkg-config executable")
+mark_as_advanced(PKG_CONFIG_EXECUTABLE)
+
+if(PKG_CONFIG_EXECUTABLE)
+ set(PKG_CONFIG_FOUND 1)
+endif(PKG_CONFIG_EXECUTABLE)
+
+
+# Unsets the given variables
+macro(_pkgconfig_unset var)
+ set(${var} "" CACHE INTERNAL "")
+endmacro(_pkgconfig_unset)
+
+macro(_pkgconfig_set var value)
+ set(${var} ${value} CACHE INTERNAL "")
+endmacro(_pkgconfig_set)
+
+# Invokes pkgconfig, cleans up the result and sets variables
+macro(_pkgconfig_invoke _pkglist _prefix _varname _regexp)
+ set(_pkgconfig_invoke_result)
+
+ execute_process(
+ COMMAND ${PKG_CONFIG_EXECUTABLE} ${ARGN} ${_pkglist}
+ OUTPUT_VARIABLE _pkgconfig_invoke_result
+ RESULT_VARIABLE _pkgconfig_failed)
+
+ if (_pkgconfig_failed)
+ set(_pkgconfig_${_varname} "")
+ _pkgconfig_unset(${_prefix}_${_varname})
+ else(_pkgconfig_failed)
+ string(REGEX REPLACE "[\r\n]" " " _pkgconfig_invoke_result "${_pkgconfig_invoke_result}")
+ string(REGEX REPLACE " +$" "" _pkgconfig_invoke_result "${_pkgconfig_invoke_result}")
+
+ if (NOT ${_regexp} STREQUAL "")
+ string(REGEX REPLACE "${_regexp}" " " _pkgconfig_invoke_result "${_pkgconfig_invoke_result}")
+ endif(NOT ${_regexp} STREQUAL "")
+
+ separate_arguments(_pkgconfig_invoke_result)
+
+ #message(STATUS " ${_varname} ... ${_pkgconfig_invoke_result}")
+ set(_pkgconfig_${_varname} ${_pkgconfig_invoke_result})
+ _pkgconfig_set(${_prefix}_${_varname} "${_pkgconfig_invoke_result}")
+ endif(_pkgconfig_failed)
+endmacro(_pkgconfig_invoke)
+
+# Invokes pkgconfig two times; once without '--static' and once with
+# '--static'
+macro(_pkgconfig_invoke_dyn _pkglist _prefix _varname cleanup_regexp)
+ _pkgconfig_invoke("${_pkglist}" ${_prefix} ${_varname} "${cleanup_regexp}" ${ARGN})
+ _pkgconfig_invoke("${_pkglist}" ${_prefix} STATIC_${_varname} "${cleanup_regexp}" --static ${ARGN})
+endmacro(_pkgconfig_invoke_dyn)
+
+# Splits given arguments into options and a package list
+macro(_pkgconfig_parse_options _result _is_req)
+ set(${_is_req} 0)
+
+ foreach(_pkg ${ARGN})
+ if (_pkg STREQUAL "REQUIRED")
+ set(${_is_req} 1)
+ endif (_pkg STREQUAL "REQUIRED")
+ endforeach(_pkg ${ARGN})
+
+ set(${_result} ${ARGN})
+ list(REMOVE_ITEM ${_result} "REQUIRED")
+endmacro(_pkgconfig_parse_options)
+
+###
+macro(_pkg_check_modules_internal _is_required _is_silent _prefix)
+ _pkgconfig_unset(${_prefix}_FOUND)
+ _pkgconfig_unset(${_prefix}_VERSION)
+ _pkgconfig_unset(${_prefix}_PREFIX)
+ _pkgconfig_unset(${_prefix}_INCLUDEDIR)
+ _pkgconfig_unset(${_prefix}_LIBDIR)
+ _pkgconfig_unset(${_prefix}_LIBS)
+ _pkgconfig_unset(${_prefix}_LIBS_L)
+ _pkgconfig_unset(${_prefix}_LIBS_PATHS)
+ _pkgconfig_unset(${_prefix}_LIBS_OTHER)
+ _pkgconfig_unset(${_prefix}_CFLAGS)
+ _pkgconfig_unset(${_prefix}_CFLAGS_I)
+ _pkgconfig_unset(${_prefix}_CFLAGS_OTHER)
+ _pkgconfig_unset(${_prefix}_STATIC_LIBDIR)
+ _pkgconfig_unset(${_prefix}_STATIC_LIBS)
+ _pkgconfig_unset(${_prefix}_STATIC_LIBS_L)
+ _pkgconfig_unset(${_prefix}_STATIC_LIBS_PATHS)
+ _pkgconfig_unset(${_prefix}_STATIC_LIBS_OTHER)
+ _pkgconfig_unset(${_prefix}_STATIC_CFLAGS)
+ _pkgconfig_unset(${_prefix}_STATIC_CFLAGS_I)
+ _pkgconfig_unset(${_prefix}_STATIC_CFLAGS_OTHER)
+
+ # create a better addressable variable of the modules and calculate its size
+ set(_pkg_check_modules_list ${ARGN})
+ list(LENGTH _pkg_check_modules_list _pkg_check_modules_cnt)
+
+ if(PKG_CONFIG_EXECUTABLE)
+ # give out status message telling checked module
+ if (NOT ${_is_silent})
+ if (_pkg_check_modules_cnt EQUAL 1)
+ message(STATUS "checking for module '${_pkg_check_modules_list}'")
+ else(_pkg_check_modules_cnt EQUAL 1)
+ message(STATUS "checking for modules '${_pkg_check_modules_list}'")
+ endif(_pkg_check_modules_cnt EQUAL 1)
+ endif(NOT ${_is_silent})
+
+ set(_pkg_check_modules_packages)
+ set(_pkg_check_modules_failed)
+
+ # iterate through module list and check whether they exist and match the required version
+ foreach (_pkg_check_modules_pkg ${_pkg_check_modules_list})
+ set(_pkg_check_modules_exist_query)
+
+ # check whether version is given
+ if (_pkg_check_modules_pkg MATCHES ".*(>=|=|<=).*")
+ string(REGEX REPLACE "(.*[^><])(>=|=|<=)(.*)" "\\1" _pkg_check_modules_pkg_name "${_pkg_check_modules_pkg}")
+ string(REGEX REPLACE "(.*[^><])(>=|=|<=)(.*)" "\\2" _pkg_check_modules_pkg_op "${_pkg_check_modules_pkg}")
+ string(REGEX REPLACE "(.*[^><])(>=|=|<=)(.*)" "\\3" _pkg_check_modules_pkg_ver "${_pkg_check_modules_pkg}")
+ else(_pkg_check_modules_pkg MATCHES ".*(>=|=|<=).*")
+ set(_pkg_check_modules_pkg_name "${_pkg_check_modules_pkg}")
+ set(_pkg_check_modules_pkg_op)
+ set(_pkg_check_modules_pkg_ver)
+ endif(_pkg_check_modules_pkg MATCHES ".*(>=|=|<=).*")
+
+ # handle the operands
+ if (_pkg_check_modules_pkg_op STREQUAL ">=")
+ list(APPEND _pkg_check_modules_exist_query --atleast-version)
+ endif(_pkg_check_modules_pkg_op STREQUAL ">=")
+
+ if (_pkg_check_modules_pkg_op STREQUAL "=")
+ list(APPEND _pkg_check_modules_exist_query --exact-version)
+ endif(_pkg_check_modules_pkg_op STREQUAL "=")
+
+ if (_pkg_check_modules_pkg_op STREQUAL "<=")
+ list(APPEND _pkg_check_modules_exist_query --max-version)
+ endif(_pkg_check_modules_pkg_op STREQUAL "<=")
+
+ # create the final query which is of the format:
+ # * --atleast-version <version> <pkg-name>
+ # * --exact-version <version> <pkg-name>
+ # * --max-version <version> <pkg-name>
+ # * --exists <pkg-name>
+ if (_pkg_check_modules_pkg_op)
+ list(APPEND _pkg_check_modules_exist_query "${_pkg_check_modules_pkg_ver}")
+ else(_pkg_check_modules_pkg_op)
+ list(APPEND _pkg_check_modules_exist_query --exists)
+ endif(_pkg_check_modules_pkg_op)
+
+ _pkgconfig_unset(${_prefix}_${_pkg_check_modules_pkg_name}_VERSION)
+ _pkgconfig_unset(${_prefix}_${_pkg_check_modules_pkg_name}_PREFIX)
+ _pkgconfig_unset(${_prefix}_${_pkg_check_modules_pkg_name}_INCLUDEDIR)
+ _pkgconfig_unset(${_prefix}_${_pkg_check_modules_pkg_name}_LIBDIR)
+
+ list(APPEND _pkg_check_modules_exist_query "${_pkg_check_modules_pkg_name}")
+ list(APPEND _pkg_check_modules_packages "${_pkg_check_modules_pkg_name}")
+
+ # execute the query
+ execute_process(
+ COMMAND ${PKG_CONFIG_EXECUTABLE} ${_pkg_check_modules_exist_query}
+ RESULT_VARIABLE _pkgconfig_retval)
+
+ # evaluate result and tell failures
+ if (_pkgconfig_retval)
+ if(NOT ${_is_silent})
+ message(STATUS " package '${_pkg_check_modules_pkg}' not found")
+ endif(NOT ${_is_silent})
+
+ set(_pkg_check_modules_failed 1)
+ endif(_pkgconfig_retval)
+ endforeach(_pkg_check_modules_pkg)
+
+ if(_pkg_check_modules_failed)
+ # fail when requested
+ if (${_is_required})
+ message(SEND_ERROR "A required package was not found")
+ endif (${_is_required})
+ else(_pkg_check_modules_failed)
+ # when we are here, we checked whether requested modules
+ # exist. Now, go through them and set variables
+
+ _pkgconfig_set(${_prefix}_FOUND 1)
+ list(LENGTH _pkg_check_modules_packages pkg_count)
+
+ # iterate through all modules again and set individual variables
+ foreach (_pkg_check_modules_pkg ${_pkg_check_modules_packages})
+ # handle case when there is only one package required
+ if (pkg_count EQUAL 1)
+ set(_pkg_check_prefix "${_prefix}")
+ else(pkg_count EQUAL 1)
+ set(_pkg_check_prefix "${_prefix}_${_pkg_check_modules_pkg}")
+ endif(pkg_count EQUAL 1)
+
+ _pkgconfig_invoke(${_pkg_check_modules_pkg} "${_pkg_check_prefix}" VERSION "" --modversion )
+ _pkgconfig_invoke(${_pkg_check_modules_pkg} "${_pkg_check_prefix}" PREFIX "" --variable=prefix )
+ _pkgconfig_invoke(${_pkg_check_modules_pkg} "${_pkg_check_prefix}" INCLUDEDIR "" --variable=includedir )
+ _pkgconfig_invoke(${_pkg_check_modules_pkg} "${_pkg_check_prefix}" LIBDIR "" --variable=libdir )
+
+ message(STATUS " found ${_pkg_check_modules_pkg}, version ${_pkgconfig_VERSION}")
+ endforeach(_pkg_check_modules_pkg)
+
+ # set variables which are combined for multiple modules
+ _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" LIBRARIES "(^| )-l" --libs-only-l )
+ _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" LIBRARY_DIRS "(^| )-L" --libs-only-L )
+ _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" LDFLAGS "" --libs )
+ _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" LDFLAGS_OTHER "" --libs-only-other )
+
+ _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" INCLUDE_DIRS "(^| )-I" --cflags-only-I )
+ _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" CFLAGS "" --cflags )
+ _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" CFLAGS_OTHER "" --cflags-only-other )
+ endif(_pkg_check_modules_failed)
+ else(PKG_CONFIG_EXECUTABLE)
+ if (${_is_required})
+ message(SEND_ERROR "pkg-config tool not found")
+ endif (${_is_required})
+ endif(PKG_CONFIG_EXECUTABLE)
+endmacro(_pkg_check_modules_internal)
+
+###
+### User visible macros start here
+###
+
+###
+macro(pkg_check_modules _prefix _module0)
+ # check cached value
+ if (NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION})
+ _pkgconfig_parse_options (_pkg_modules _pkg_is_required "${_module0}" ${ARGN})
+ _pkg_check_modules_internal("${_pkg_is_required}" 0 "${_prefix}" ${_pkg_modules})
+
+ _pkgconfig_set(__pkg_config_checked_${_prefix} ${PKG_CONFIG_VERSION})
+ endif(NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION})
+endmacro(pkg_check_modules)
+
+###
+macro(pkg_search_module _prefix _module0)
+ # check cached value
+ if (NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION})
+ set(_pkg_modules_found 0)
+ _pkgconfig_parse_options(_pkg_modules_alt _pkg_is_required "${_module0}" ${ARGN})
+
+ message(STATUS "checking for one of the modules '${_pkg_modules_alt}'")
+
+ # iterate through all modules and stop at the first working one.
+ foreach(_pkg_alt ${_pkg_modules_alt})
+ if(NOT _pkg_modules_found)
+ _pkg_check_modules_internal(0 1 "${_prefix}" "${_pkg_alt}")
+ endif(NOT _pkg_modules_found)
+
+ if (${_prefix}_FOUND)
+ set(_pkg_modules_found 1)
+ endif(${_prefix}_FOUND)
+ endforeach(_pkg_alt)
+
+ if (NOT ${_prefix}_FOUND)
+ if(${_pkg_is_required})
+ message(SEND_ERROR "None of the required '${_pkg_modules_alt}' found")
+ endif(${_pkg_is_required})
+ endif(NOT ${_prefix}_FOUND)
+
+ _pkgconfig_set(__pkg_config_checked_${_prefix} ${PKG_CONFIG_VERSION})
+ endif(NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION})
+endmacro(pkg_search_module)
+
+### Local Variables:
+### mode: cmake
+### End:
diff -r 000000000000 -r 7c5f0a3fa0fe src/CMakeLists.txt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/CMakeLists.txt Tue Aug 26 05:44:10 2008 +0000
@@ -0,0 +1,5 @@
+include_directories( BEFORE ${CMAKE_SOURCE_DIR}/src )
+add_subdirectory(parser)
+add_subdirectory(panotools-wrappers)
+add_subdirectory(vips)
+#add_subdirectory(transmap)
diff -r 000000000000 -r 7c5f0a3fa0fe src/panotools-wrappers/CMakeLists.txt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/panotools-wrappers/CMakeLists.txt Tue Aug 26 05:44:10 2008 +0000
@@ -0,0 +1,16 @@
+#this is just a basic CMakeLists.txt, for more information see the cmake manpage
+
+# set include path to include the generated parser.h file
+include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/../parser )
+
+#build a shared library
+ADD_LIBRARY(panotoolswrapper SHARED pttransform.c)
+
+#for testing the shared library you probably need some test app too
+ADD_EXECUTABLE(testtransform testtransform.c pttransform.c)
+#link to the library
+TARGET_LINK_LIBRARIES(testtransform panoparser pano13 panotoolswrapper)
+
+#add an install target here
+
+INSTALL(TARGETS panotoolswrapper LIBRARY DESTINATION lib)
diff -r 000000000000 -r 7c5f0a3fa0fe src/panotools-wrappers/ChangeLog
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/panotools-wrappers/ChangeLog Tue Aug 26 05:44:10 2008 +0000
@@ -0,0 +1,16 @@
+2007-06-27 Pablo d'Angelo <pablo.dangelo@...>
+
+ * pttransform.c: bugfix: destination projection type was not converted
+ properly
+
+2007-05-30 Pablo d'Angelo <pablo.dangelo@...>
+
+ * pttransform.h pttransform.c: correct order of a,b,c parameters.
+ Better naming of transform functions
+
+2007-05-28 Pablo d'Angelo <pablo.dangelo@...>
+
+ * CMakeLists.txt README pttransform.c pttransform.h testtransform.c
+ test.pto: added simple wrapper to generate panotools transform
+ stacks using the new parser
+
diff -r 000000000000 -r 7c5f0a3fa0fe src/panotools-wrappers/README
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/panotools-wrappers/README Tue Aug 26 05:44:10 2008 +0000
@@ -0,0 +1,15 @@
+Some simplified wrapper interfaces for important operations
+in Panorama Tools (and tlalli).
+
+This directory contains wrappers for functionality that is not
+yet available in a new, rewritten form. It allows people
+to use certain features of the panotools library more easily.
+
+Currently implemented:
+
+pttransform.c/h: wrapper for coordinate transform stack.
+
+Purpose: allow easy creation of the coordinate transform stacks,
+ given a panotools script file. Useful for the VIPS GSoC
+ project, and a test suite for a new projections library.
+
diff -r 000000000000 -r 7c5f0a3fa0fe src/panotools-wrappers/pttransform.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/panotools-wrappers/pttransform.c Tue Aug 26 05:44:10 2008 +0000
@@ -0,0 +1,273 @@
+/*
+ * pttransform.c
+ *
+ * Copyright Pablo d'Angelo
+ *
+ * May 2007
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ *
+ * Author: Pablo d'Angelo pablo.dangelo@...
+ *
+ */
+
+
+#include "pttransform.h"
+
+// tables to map the script projection numbers
+// to internal projection numbers
+int srcProj2ProjMap[] = { 0, 1, 2, 3, 4 };
+int panoProj2ProjMap[] = {0, 1, 4, 3, 10, 11, 12, 14 };
+
+// internal function to setup panotools data structure
+static void srcImage2PTImg(pt_script_image * src, Image * dest)
+{
+ int i,j;
+
+ SetImageDefaults(dest);
+
+ dest->width = src->width;
+ dest->height = src->height;
+
+ // dummy entry for image storage
+ dest->bytesPerLine = dest->height*3;
+ dest->bitsPerPixel = 24;
+ dest->dataSize = 0;
+ dest->data = 0;
+ dest->dataformat = _RGB;
+
+ if (src->projection < 0 || src->projection >= sizeof(srcProj2ProjMap)/sizeof(int)) {
+ fprintf(stderr, "Warning, unknown projection format, using rectilinear\n");
+ dest->format = 0;
+ } else {
+ dest->format = srcProj2ProjMap[src->projection];
+ }
+ dest->hfov = src->fHorFOV;
+ dest->yaw = src->yaw;
+ dest->roll = src->roll;
+ dest->pitch = src->pitch;
+
+ // copy lens correction parameters
+ // radial distortion parameters
+ if (src->coef[0] != 0.0 || src->coef[1] != 0.0 || src->coef[2] != 0.0) {
+ dest->cP.radial = 1;
+ dest->cP.correction_mode = 0;
+ for (j = 0; j < 3; j++) {
+ for (i = 0; i < 3; i++) {
+ dest->cP.radial_params[j][3-i] = src->coef[i];
+ }
+ dest->cP.radial_params[j][0] = 1 - src->coef[0] - src->coef[1] - src->coef[2];
+ }
+ }
+
+ SetCorrectionRadius(&(dest->cP));
+
+ // image center shift
+ if (src->coef[4]) {
+ dest->cP.vertical = 1;
+ for (i=0; i < 3; i++)
+ dest->cP.vertical_params[i] = src->coef[4];
+ }
+ if (src->coef[3]) {
+ dest->cP.horizontal = 1;
+ for (i=0; i < 3; i++)
+ dest->cP.horizontal_params[i] = src->coef[3];
+ }
+
+ // shear
+ if (src->coef[5] != 0.0 || src->coef[6] != 0.0) {
+ dest->cP.shear = 1;
+ dest->cP.shear_x = src->coef[5];
+ dest->cP.shear_y = src->coef[6];
+ } else {
+ dest->cP.shear = 0;
+ }
+
+ dest->cP.luminance = 0;
+ dest->cP.fourier = 0;
+
+ dest->name[0] = 0;
+
+ // copy selection
+ dest->selection.left = src->cropArea[0];
+ dest->selection.top = src->cropArea[1];
+ dest->selection.right = src->cropArea[2];
+ dest->selection.bottom = src->cropArea[3];
+
+ // type of crop
+ dest->cP.cutFrame = src->cropType == 'C' ? 1 : 0;
+
+ // dest->crop information is not used by the coordinate transforms themself.
+}
+
+// internal function to setup panotools data structure
+static void destImage2PTImg(pt_script_pano * src, Image * dest)
+{
+ SetImageDefaults(dest);
+
+ dest->width = src->width;
+ dest->height = src->height;
+
+ // dummy entry for image storage
+ dest->bytesPerLine = dest->height*3;
+ dest->bitsPerPixel = 24;
+ dest->dataSize = 0;
+ dest->data = 0;
+ dest->dataformat = _RGB;
+
+ if (src->projection < 0 || src->projection >= sizeof(panoProj2ProjMap)/sizeof(int)) {
+ fprintf(stderr, "Warning, unknown projection format, using rectilinear\n");
+ dest->format = 0;
+ } else {
+ dest->format = panoProj2ProjMap[src->projection];
+ }
+ dest->hfov = src->fHorFOV;
+}
+
+
+pt_transform * panoTransformCreate(pt_script *script, int imgNr)
+{
+ pt_script_image * inputImg = panoScriptGetInputImage(script, imgNr);
+ if (! inputImg) {
+ fprintf(stderr, "image number invalid\n");
+ return NULL;
+ }
+
+ // void SetMakeParams( struct fDesc *stack, struct MakeParams *mp, Image *im , Image *pn, int color )
+ // create transformation struct
+ pt_transform * trans = (pt_transform *) malloc(sizeof(pt_transform));
+
+ // panotools data structures
+ Image imSrc;
+ Image imDest;
+
+ srcImage2PTImg(inputImg, &imSrc);
+ destImage2PTImg(&(script->pano), &imDest);
+
+ // create transformation stack. Transfroms using cartesian coordinates
+ // (origin in image centre)
+ SetMakeParams(&(trans->stack[0]), &(trans->mp), &imSrc, &imDest, 0);
+ trans->fD.func = execute_stack_new;
+ trans->fD.param = trans->stack;
+
+ // create transformation stack. Transfroms using cartesian coordinates
+ // (origin in image centre)
+ SetMakeParams(&(trans->invstack[0]), &(trans->invmp), &imSrc, &imDest, 0);
+ trans->fD.func = execute_stack_new;
+ trans->fD.param = trans->invstack;
+
+ // offset to correct for cartesion <-> image coordinate systems
+ trans->w2 = panoScriptGetPanoWidth(script) / 2.0 - 0.5; // Steve's L
+ trans->h2 = panoScriptGetPanoHeight(script) / 2.0 - 0.5;
+ trans->sw2 = inputImg->width / 2.0 - 0.5;
+ trans->sh2 = inputImg->height / 2.0 - 0.5;
+
+ // precalculate crop settings
+ if (inputImg->cropArea[0] < 0)
+ trans->crop_left = 0;
+ else
+ trans->crop_left = inputImg->cropArea[0];
+
+ if (inputImg->cropArea[1] > inputImg->width)
+ trans->crop_right = inputImg->width;
+ else
+ trans->crop_right = inputImg->cropArea[1];
+
+ if (inputImg->cropArea[2] < 0)
+ trans->crop_top = 0;
+ else
+ trans->crop_top = inputImg->cropArea[2];
+
+ if (inputImg->cropArea[3] > inputImg->height)
+ trans->crop_bottom = 0;
+ else
+ trans->crop_bottom = inputImg->cropArea[3];
+
+ if (inputImg->projection == 2) {
+ double r1, r2;
+ trans->crop_circular = 1;
+ // TODO: calculate crop centre and radius
+ trans->crop_circular_cx = (inputImg->cropArea[0] + inputImg->cropArea[1]) / 2.0;
+ trans->crop_circular_cy = (inputImg->cropArea[2] + inputImg->cropArea[3]) / 2.0;
+ r1 = (inputImg->cropArea[1] - inputImg->cropArea[0]) / 2.0;
+ r2 = (inputImg->cropArea[3] - inputImg->cropArea[2]) / 2.0;
+ if (r1 < r2)
+ trans->crop_circular_radius = r1;
+ else
+ trans->crop_circular_radius = r2;
+ } else {
+ trans->crop_circular = 0;
+ }
+
+ return trans;
+}
+
+int panoTransformForward(pt_transform *transform,
+ double x_in, double y_in, double *x_out, double *y_out )
+{
+ // convert destination screen coordinates to cartesian coordinates
+ x_in -= transform->sw2;
+ y_in -= transform->sh2;
+ // get source cartesian coordinates
+ int valid = transform->fD.func(x_in, y_in, x_out, y_out, transform->fD.param);
+ if (! valid) return FALSE;
+ // convert source cartesian coordinates to screen coordinates
+ *x_out += transform->w2;
+ *y_out += transform->h2;
+
+ // TODO: calculate distance from image border
+ // useful for later seam creation
+}
+
+
+int panoTransformInverse(pt_transform *transform,
+ double x_out, double y_out, double *x_in, double *y_in )
+{
+ // convert destination screen coordinates to cartesian coordinates
+ x_out -= transform->w2;
+ y_out -= transform->h2;
+ // get source cartesian coordinates
+ int valid = transform->fD.func(x_out, y_out, x_in, y_in, transform->fD.param);
+ if (! valid) return FALSE;
+ // convert source cartesian coordinates to screen coordinates
+ *x_in += transform->sw2;
+ *y_in += transform->sh2;
+
+ // check if this is inside the source image/crop
+ valid = valid && (! (*x_in < transform->crop_left || *x_in >= transform->crop_right ||
+ *y_in < transform->crop_top || *y_in >= transform->crop_bottom));
+
+ if (transform->crop_circular) {
+ // circular crop
+ double rx = *x_in - transform->crop_circular_cx;
+ double ry = *y_in - transform->crop_circular_cy;
+ double r = sqrt(rx * rx + ry * ry);
+ valid = valid && (r < transform->crop_circular_radius);
+ }
+ return valid;
+
+ // TODO: calculate distance from image border
+ // useful for later seam creation
+}
+
+void panoTransformDispose(pt_transform **transform)
+{
+ if (*transform) {
+ free(*transform);
+ }
+ *transform = 0;
+}
+
diff -r 000000000000 -r 7c5f0a3fa0fe src/panotools-wrappers/pttransform.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/panotools-wrappers/pttransform.h Tue Aug 26 05:44:10 2008 +0000
@@ -0,0 +1,115 @@
+/*
+ * pttransform.h
+ *
+ * Copyright Pablo d'Angelo
+ *
+ * May 2007
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ *
+ * Author: Pablo d'Angelo pablo.dangelo@...
+ *
+ */
+
+
+#include <stdio.h>
+
+#include "parser/tparser.h"
+
+#include <pano13/panorama.h>
+#include <pano13/filter.h>
+
+
+/** state of a transform.
+ *
+ * Internal data structure, do not access directly
+ *
+ */
+typedef struct
+{
+ struct MakeParams mp;
+ fDesc stack[15], fD; // Parameters for execute
+
+ // inverse (src image -> pano image) transform
+ struct MakeParams invmp;
+ fDesc invstack[15], invfD; // Parameters for execute
+
+ // descriptions of panorama and source image
+ pt_script_pano pano;
+ pt_script_image src;
+ double w2, h2, sw2, sh2;
+ int crop_circular;
+ double crop_circular_cx;
+ double crop_circular_cy;
+ double crop_circular_radius;
+ double crop_radius;
+ double crop_centre;
+ double crop_left;
+ double crop_right;
+ double crop_top;
+ double crop_bottom;
+} pt_transform;
+
+
+/** Create a panotools transform
+ *
+ * @param script path to panotools script file. Created with parser by Daniel
+ * @param imgNr number of input image
+ *
+ * @return pano_transform_ptr pointer to transform struct. needs to be released
+ * with panoTransformDispose
+ */
+pt_transform * panoTransformCreate(pt_script * script, int imgNr);
+
+
+/** Transform coordinates (inverse transform)
+ *
+ * @param x_dest x (input) coordinate in destination (panorama) image
+ * @param y_dest y (input) coordinate in destination (panorama) image
+ *
+ * @param x_src x (output) coordinate in source (input) image
+ * @param y_src y (output) coordinate in source (input) image
+ *
+ * @return 0: outside source image, x_src, y_src are not valid,
+ * either not possible in this projection, or outside
+ * the image.
+ * 1: inside src image, x_src, y_src valid.
+ *
+ */
+int panoTransformInverse(pt_transform *transform,
+ double x_dest, double y_dest, double *x_src, double *y_src );
+
+
+/** Transform coordinates (forward transform)
+ *
+ * @param x_src x (input) coordinate in source (input) image
+ * @param y_src y (input) coordinate in source (input) image
+ *
+ * @param x_dest x (output) coordinate in destination (panorama) image
+ * @param y_dest y (output) coordinate in destination (panorama) image
+ *
+ * @return 0: outside source image, x_dest, y_dest are not valid,
+ * 1: inside src image, x_dest, y_dest valid.
+ *
+ */
+int panoTransformForward(pt_transform *transform,
+ double x_src, double y_src, double *x_dest, double *y_dest );
+
+
+/** Free a pt_transform struct
+ */
+void panoTransformDispose(pt_transform **transform);
+
diff -r 000000000000 -r 7c5f0a3fa0fe src/panotools-wrappers/test.pto
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/panotools-wrappers/test.pto Tue Aug 26 05:44:10 2008 +0000
@@ -0,0 +1,20 @@
+# PTOptimizer script, written by hugin
+
+p f0 w10 h10 v36 n"PNG"
+m g1 i2 f0
+
+# image lines
+i w100 h100 f0 v36 y0 u10 n"test.jpg"
+
+
+# specify variables that should be optimized
+v p0 r0 v0
+v
+
+# control points
+c n0 N0 x38 y827 X849 Y841 t2
+c n0 N0 x1551 y831 X821 Y842 t2
+c n0 N0 x1633 y829 X102 Y829 t2
+c n0 N0 x879 y844 X2028 Y822 t2
+
+#hugin_options r0 e2
diff -r 000000000000 -r 7c5f0a3fa0fe src/panotools-wrappers/testtransform.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/panotools-wrappers/testtransform.c Tue Aug 26 05:44:10 2008 +0000
@@ -0,0 +1,73 @@
+/*
+ * testtransform.c
+ *
+ * Copyright Pablo d'Angelo
+ *
+ * May 2007
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ *
+ * Author: Pablo d'Angelo pablo.dangelo@...
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdarg.h>
+#include <assert.h>
+
+#include <parser/tparser.h>
+#include "pttransform.h"
+
+
+int main(int argc, char *argv[])
+{
+ int i,x,y;
+
+ pt_script *script = NULL;
+
+ printf("Testing transform functions\n");
+ if (argc != 2) {
+ fprintf(stderr, "Usage: testtransforms panotools_script.txt");
+ }
+
+ script = panoScriptParse(argv[1], TRUE);
+ if (script == NULL) {
+ printf("Parsing error\n");
+ } else {
+ panoScriptDump(script);
+
+ printf("\n\n===============================\n\n");
+
+ pt_transform * t = panoTransformCreate(script,0);
+ double xs, ys;
+ for (y=0; y < script->pano.width; ++y) {
+ for (x=0; x < script->pano.height; ++x) {
+ panoTransformInverse(t, x,y, &xs,&ys);
+ printf("%f, %f ", xs, ys);
+ }
+ printf("\n", xs, ys);
+ }
+ panoTransformDispose(&t);
+
+ panoParserDispose(&script);
+ }
+
+ return 0;
+}
+
diff -r 000000000000 -r 7c5f0a3fa0fe src/parser/AUTHORS
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/parser/AUTHORS Tue Aug 26 05:44:10 2008 +0000
@@ -0,0 +1,1 @@
+Daniel M. German - http://turingmachine.org/
diff -r 000000000000 -r 7c5f0a3fa0fe src/parser/CMakeLists.txt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/parser/CMakeLists.txt Tue Aug 26 05:44:10 2008 +0000
@@ -0,0 +1,34 @@
+# these two variables were not defined for me
+
+SET(FLEX_EXECUTABLE flex)
+SET(BISON_EXECUTABLE bison)
+
+ADD_DEFINITIONS(-std=gnu99)
+ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/parser.c ${CMAKE_CURRENT_BINARY_DIR}/parser.h
+ COMMAND ${BISON_EXECUTABLE} -d -oparser.c ${CMAKE_CURRENT_SOURCE_DIR}/parser.y
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/parser.y )
+
+ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/scanner.c
+ COMMAND ${FLEX_EXECUTABLE} -oscanner.c ${CMAKE_CURRENT_SOURCE_DIR}/scanner.l
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/scanner.l )
+
+# set include path to include the generated parser.h file
+include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} )
+
+#build a shared library
+ADD_LIBRARY(tparser SHARED tparser.c
+ ${CMAKE_CURRENT_BINARY_DIR}/parser.c
+ ${CMAKE_CURRENT_BINARY_DIR}/scanner.c )
+
+#for testing the shared library you probably need some test app too
+ADD_EXECUTABLE(testparser testparser.c tparser.c
+ ${CMAKE_CURRENT_BINARY_DIR}/parser.c
+ ${CMAKE_CURRENT_BINARY_DIR}/scanner.c
+ )
+
+#link to the library
+TARGET_LINK_LIBRARIES(testparser m)
+
+# installation targets
+INSTALL(TARGETS tparser LIBRARY DESTINATION lib)
+INSTALL(FILES tparser.h DESTINATION include/tparser)
diff -r 000000000000 -r 7c5f0a3fa0fe src/parser/COPYING
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/parser/COPYING Tue Aug 26 05:44:10 2008 +0000
@@ -0,0 +1,340 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff -r 000000000000 -r 7c5f0a3fa0fe src/parser/ChangeLog
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/parser/ChangeLog Tue Aug 26 05:44:10 2008 +0000
@@ -0,0 +1,131 @@
+2008-08-25 dmg <dmg@...>
+
+ * .svnignore: ignore many files
+
+ * tparser.h, tparser.c, testparser.c: The parser no longer
+ allocates the parsing data structure, instead it is passed as a
+ parameter.
+
+2008-08-24 dmg <dmg@...>
+
+ * parser.y (PT_TOKEN_STRING): Check that the gamma is > 0.
+ huberEstimator is a float, not int
+
+2008-08-10 dmg <dmg@...>
+
+ * CMakeLists.txt: Changed name of library to tparser, added
+ tparser.h as a file to install
+
+2008-08-10 dmg <dmg@...>
+
+ * scanner.l, parser.y: Finally! properly handle end-of-input.
+
+ * CMakeLists.txt: Added GCC declaration for GCC compilation of
+ lround. It might not work on other compilers. This needs ot be fixed.
+
+ * tparser.h: Added declarations to remove warning
+
+2007-06-28 dmg <dmg@...>
+
+ * parser.y, tparser.c, tparser.h, scanner.l: I think I finished
+ implementing all the hugin specific parameters.
+
+ * tparser.h, tparser.h, tparser.c: Added all the variables needed
+ by Hugin, renamed some of them.
+
+ * parser.y, tparser.c, tparser.h: Implemented R variable in p-line
+
+ * parser.y, tparser.c, tparser.h, scanner.l: Implemented Hugin
+ autoCenterCrop and cropFactor in i-lines.
+
+2007-06-27 dmg <dmg@...>
+
+ * parser.y, tparser.c, tparser.h, scanner.l: Implemented Ra...Re
+ variables and their references
+
+ * parser.y, tparser.c, tparser.h: implemented hugin_options
+ variables r and e.
+
+ * Removed several debugging messages to make the output cleaner.
+
+ * parser.y: Improved error handling in case of unrecognized
+ lines. Previously it was stopping at the first line it did not
+ recognized, but returned no error.
+
+ * parser.y, tparser.c, tparser.h (struct): Added parameters
+ outputPixelType and photometricHuberSigma. Added feather size (u)
+ in images lines
+
+ * scanner.l: Added token for #-hugin variables.
+
+2007-06-14 dmg <dmg@...>
+
+ * parser.y (PT_TOKEN_STRING): Removed yydebug for the time being.
+
+ * tparserdebug.h (DEBUG_2): THe #else had the wrong number of parms.
+
+ * parser.y: Fixed an out-of-bounds error.
+
+ * tparserdebug.h, parser.y, tparser.c: added this file.
+
+2007-06-09 Pablo d'Angelo <pablo.dangelo@...>
+
+ * CMakeLists.txt: build a library for the parser anyway, this is
+ required for the transform wrapper. Added link to lm, required on
+ unix. I hope it still works on OSX.
+
+2007-06-06 dmg <dmg@...>
+
+ * CMakeLists.txt: Fixed script. At least it now creates the test executable
+
+ * Tparser.c (panoParserDumpImage): Fixed a compilation error that
+ slip through in my last commit
+
+ * Added support for reading control points.
+
+2007-05-13 dmg <dmg@...>
+
+ * scanner.l, parser.y: Changed PT_TOKEN_FLOAT to
+ PT_TOKEN_NUMBER. Removed PT_TOKEN_INT. Now all numbers are float,
+ but down-converted to int if necessary (using lroundf). Created a
+ new token for cropping (PT_TOKEN_CROPPING). It simplifies error messages.
+
+2007-05-03 dmg <dmg@...>
+
+ * parser.y (PT_TOKEN_STRING): Fixed spelling mistake in huberEstimator
+
+ * tparser.c (panoScriptParse): Fixed spelling mistake in name of parameter
+
+2007-04-18 dmg <dmg@...>
+
+ * tparser.c, tparser.h: Renamed some functions to the tlalli naming
+ standards. Added functions to parse projection parameters. Added
+ functions to de-reference variables. Added a function to dump the
+ content of the script variable. Fixed some bugs.
+
+ * tparserprivate.h: Added this file to keep any declarations that
+ are only required to by parser.
+
+ * parser.y: Clear newly allocated memory for image specs
+
+ * testparser.c: Added logic to dereference variables. Moved
+ dumping of variables to a function in tparser.c
+
+
+2007-04-11 pablo <pablo.dangelo@...>
+
+ * CMakeLists.txt, CMakeModules/FindBISON.cmake,
+ CMakeModules/FindFLEX.cmake, src/CMakeLists.txt,
+ src/parser/CMakeLists.txt: CMake based build system
+
+ * src/parser/tparser.c, src/parser/testparser.c: Moved main into a
+ separate file, build library and test program. Added panoPrintError()
+ function.
+
+2007-04-10 dmg <dmg@...>
+
+ * scanner.y, parser.l, tparser.h, tparser.c, README.txt, COPYING,
+ Makefile.am, ChangeLog, AUTHORS: First commit. Iimplement a simple
+ bison/yacc parser for the panotools/hugin scripts.
+
+
diff -r 000000000000 -r 7c5f0a3fa0fe src/parser/Makefile.am
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/parser/Makefile.am Tue Aug 26 05:44:10 2008 +0000
@@ -0,0 +1,26 @@
+DEFAULT_INCLUDES="-I."
+
+TLALILIB=tlalli
+
+AM_CPPFLAGS = $(JAVA_FLAGS) $(LIN_DEFS) $(DAR_DEFS) $(TIFF_FLAGS) $(JPEG_FLAGS)
+AM_LDFLAGS = -L${top_builddir}
+
+BUILT_SOURCES = parser.h parser.c scanner.c
+
+AM_YFLAGS = -d
+AM_LFLAGS = -o$(LEX_OUTPUT_ROOT).c
+
+INCLUDES = -I${top_srcdir}
+
+AM_CPPFLAGS = $(LIN_DEFS) $(DAR_DEFS)
+AM_LDFLAGS = -L${top_builddir}
+
+bin_PROGRAMS = Tparser
+
+Tparser_SOURCES = Tparser.c parser.y scanner.l parser.h tparser.h testparser.c
+Tparser_LDADD = -l${TLALILIB} -lfl -lm
+
+MAINTAINERCLEANFILES = \
+ Makefile.in
+
+
diff -r 000000000000 -r 7c5f0a3fa0fe src/parser/README.txt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/parser/README.txt Tue Aug 26 05:44:10 2008 +0000
@@ -0,0 +1,42 @@
+Parser for panotools and hugin configuration scripts.
+
+Contents:
+
+* Usage
+* Todo
+
+
+----------------------------------------------------------------------
+USAGE:
+
+This bison/yacc parser implements a simple parser that reads a file
+and converts it into an equivalent data structure. The main function
+to use is:
+
+
+pt_script *panoParseScript(char *filename)
+
+
+It returns an allocated data structure pt_script. It should be
+disposed properly using panoParseDispose.
+
+
+void panoParseDispose(pt_script **scriptVar)
+
+
+----------------------------------------------------------------------
+TODO:
+
+* Add support for K and V variables in hugin
+
+* Create a bunch of test cases
+
+* Create an include file for internal use, and one for exports.
+
+* Add support for en error function pointer so it can be replaced
+
+* Refactor the code to dump the data structure into a function that
+ can be used for debugging/testing
+
+* We need a function to verify that the read values are meaningful but
+ perhaps that is outside the scope of the parser.
diff -r 000000000000 -r 7c5f0a3fa0fe src/parser/TODO
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/parser/TODO Tue Aug 26 05:44:10 2008 +0000
@@ -0,0 +1,23 @@
+
+* The parser needs to implement the 'v' lines
+
+* C and morph-to lines are to be tested
+
+* Implement variables r and e in hugin_options
+ r: optimizeReferenceImage
+ e: blendMode
+
+
+
+
+> #2. Also, there is a variable R in the pano line. What is it? it is the
+> same as #hugin_options r0?
+
+No, it specifies the output mode: 0: LDR, 1: HDR
+
+> #3. Should I treat Ee, Er and Eb as an array of 3 values? if so, in
+> which order? I will assume they are not linkable.
+
+Eev should be separate its the photographic Exposure Value.
+Er and Eb are the white balance factors, I'd just keep the separate.
+
diff -r 000000000000 -r 7c5f0a3fa0fe src/parser/parser.y
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/parser/parser.y Tue Aug 26 05:44:10 2008 +0000
@@ -0,0 +1,724 @@
+/*
+ * parser.y
+ *
+ * Copyright Daniel M. German
+ *
+ * April 2007
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ *
+ * Author: Daniel M German dmgerman at uvic doooot ca
+ *
+ */
+
+%{
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #include <math.h>
+
+ /* #define lround gaaekraf adf adf
+ #define lroundf gaaekraf adf adf
+*/
+
+#include "tparser.h"
+#include "tparserprivate.h"
+#include "tparserdebug.h"
+
+ int yylex (void);
+ void yyerror (char const *);
+/* Keeps track of the current type of input line in the file */
+int currentLine = -1;
+
+pt_script script;
+
+/* defining it gives better error messages. It might be an overkill */
+#define YYERROR_VERBOSE 1
+
+static pt_script_image *image;
+static pt_script_ctrl_point *ctrlPoint;
+static pt_script_morph_point *morphPoint;
+
+// Look ahead variables
+// Hugin uses a comment line _before_ the i line: for example
+// #-hugin autoCenterCrop=1 cropFactor=1
+
+#define PT_AUTO_CENTER_CROP_ST "autoCenterCrop"
+#define PT_AUTO_CENTER_CROP_DEFAULT 0
+static int autoCenterCrop = PT_AUTO_CENTER_CROP_DEFAULT;
+
+
+#define PT_CROP_FACTOR_ST "cropFactor"
+#define PT_CROP_FACTOR_DEFAULT 0
+static int cropFactor = PT_CROP_FACTOR_DEFAULT;
+
+/* copy a string while allocating and checking for memory */
+static void ParserStringCopy(char **dest, char *from)
+{
+ if (*dest)
+ free(*dest);
+ *dest = strdup(from);
+ if (*dest == NULL)
+ panoScriptParserError(1,"Not enough memory");
+}
+
+
+%}
+
+%defines
+
+%union {
+ int iVal;
+ float fVal;
+ char strVal[PT_TOKEN_MAX_LEN+1];
+ char cVal;
+}
+
+
+%token NUM
+%token PT_TOKEN_SEP
+%token <fVal> PT_TOKEN_NUMBER
+%token <strVal> PT_TOKEN_STRING
+%token <strVal> PT_TOKEN_HUGIN_KEYWORD
+%token <cVal> PT_TOKEN_KEYWORD
+%token <cVal> PT_TOKEN_CROPPING
+
+%token PT_TOKEN_EOL
+%token PT_TOKEN_SEPARATOR
+%token PT_TOKEN_INPUT_LINE
+%token PT_TOKEN_OUTPUT_LINE
+%token PT_TOKEN_PANO_LINE
+%token PT_TOKEN_OPTIMIZE_LINE
+%token PT_TOKEN_CONTROL_PT_LINE
+%token PT_TOKEN_COMMA
+%token PT_TOKEN_REFERENCE
+%token PT_TOKEN_MORPH_PT_LINE
+%token PT_TOKEN_HUGIN_LINE
+%token PT_TOKEN_HUGIN_OPTIONS_LINE
+%token PT_TOKEN_ERROR
+%token PT_TOKEN_EOF
+
+%start input
+
+%% /* Grammar rules and actions follow. */
+
+input: lines PT_TOKEN_EOF
+ {
+ int i;
+ DEBUG_1("Lines");
+
+ pt_script_morph_point *morphPoint2;
+ int image;
+ pt_script_image *imageSpec;
+ // We have to move the morphing control points to their corresponding images
+ DEBUG_2("Number of control points %d", script.iMorphPointsCount);
+
+ for (i = 0; i < script.iMorphPointsCount; i++) {
+ // get a pointer to the point to make life easier
+ morphPoint = &morphPointsSpec[i];
+ image = morphPoint->iImage;
+ // we need to verify that the iamge pointer exists
+ if (image < 0 || image > script.iInputImagesCount) {
+ panoScriptParserError(0,"Morphing control point number %d references non existent input image [%c].\n", i, image);
+ return -1;
+ }
+ // point to the image, avoids long dereferrencing
+ imageSpec = &script.inputImageSpec[image];
+
+ // allocate the pointer
+ morphPoint2 = (pt_script_morph_point *)panoScriptReAlloc((void*)&imageSpec->morphPoints,
+ sizeof(pt_script_morph_point), &imageSpec->morphPointsCount);
+
+ memcpy(morphPoint2, morphPoint, sizeof(pt_script_morph_point));
+ }
+ DEBUG_2("Lines: number of images %d", script.iInputImagesCount);
+
+ for (i=0;i<script.iInputImagesCount; i++) {
+ DEBUG_2("Image %d", script.inputImageSpec[i].morphPointsCount);
+ }
+ DEBUG_2("Number of control points %d", script.iMorphPointsCount);
+
+ return 0;
+ }
+
+lines:
+ | line input
+{
+ printf("Per line...\n");
+}
+
+line: eoln { }
+ | inputline
+ | outputline
+ | panoline
+ | optimizeline
+ | ctrlPtsLine
+ | morphPtsLine
+ | huginImageParmsLine
+ | huginOptionsLine
+ | parsingError
+;
+
+
+parsingError: PT_TOKEN_ERROR
+{
+ return -1;
+} PT_TOKEN_SEPARATOR ;
+
+huginOptionsLine: PT_TOKEN_HUGIN_OPTIONS_LINE PT_TOKEN_SEPARATOR
+ {
+ currentLine = PT_TOKEN_HUGIN_OPTIONS_LINE;
+ } vars eoln
+
+
+huginImageParmsLine: PT_TOKEN_HUGIN_LINE PT_TOKEN_SEPARATOR
+ {
+ currentLine = PT_TOKEN_HUGIN_LINE;
+ }
+ huginVars
+ eoln { ; }
+//
+
+
+ctrlPtsLine: PT_TOKEN_CONTROL_PT_LINE PT_TOKEN_SEPARATOR
+ {
+ currentLine = PT_TOKEN_CONTROL_PT_LINE;
+ ctrlPoint = (pt_script_ctrl_point *)panoScriptReAlloc((void*)&script.ctrlPointsSpec,
+ sizeof(pt_script_ctrl_point), &script.iCtrlPointsCount);
+ }
+ varsparms eoln { ; }
+
+morphPtsLine: PT_TOKEN_MORPH_PT_LINE PT_TOKEN_SEPARATOR
+ {
+ currentLine = PT_TOKEN_MORPH_PT_LINE;
+ morphPoint = (pt_script_morph_point *)panoScriptReAlloc((void*)&morphPointsSpec,
+ sizeof(pt_script_morph_point), &script.iMorphPointsCount);
+ }
+ varsparms eoln { ; }
+
+
+eoln: PT_TOKEN_EOL { currentLine = -1; /* This says we don't know the type of line being processed */}
+
+inputline: PT_TOKEN_INPUT_LINE PT_TOKEN_SEPARATOR
+ {
+
+ currentLine = PT_TOKEN_INPUT_LINE;
+
+ image = (pt_script_image *)panoScriptReAlloc((void*)&(script.inputImageSpec),
+ sizeof(pt_script_image), &script.iInputImagesCount);
+
+ // This might require more though. Are the defaults of these two variables zero?
+ image->autoCenterCrop = autoCenterCrop;
+ image->cropFactor = cropFactor;
+ cropFactor = PT_CROP_FACTOR_DEFAULT;
+ autoCenterCrop = PT_AUTO_CENTER_CROP_DEFAULT;
+
+
+#ifdef asdfasf
+ // allocate the new output
+ script.iInputImagesCount++;
+ script.inputImageSpec = realloc(script.inputImageSpec,
+ sizeof(*script.inputImageSpec) * script.iInputImagesCount);
+ if (script.inputImageSpec == NULL) {
+ yyerror("Not enough memory");
+ }
+ // clear the end of the reallocated region
+ bzero(&(script.inputImageSpec[script.iInputImagesCount-1]), sizeof(*script.inputImageSpec));
+ image = &script.inputImageSpec[script.iInputImagesCount-1];
+#endif
+ }
+ vars eoln { ; }
+
+outputline: PT_TOKEN_OUTPUT_LINE PT_TOKEN_SEPARATOR
+ {
+ DEBUG_1("Reading outputline");
+ currentLine = PT_TOKEN_OUTPUT_LINE;
+ // allocate the new output
+ script.iOutputImagesCount++;
+ script.outputImageSpec = realloc(script.outputImageSpec,
+ sizeof(*script.outputImageSpec) * script.iOutputImagesCount);
+ if (script.outputImageSpec == NULL) {
+ yyerror("Not enough memory");
+ }
+ // clear the end of the reallocated region
+ bzero(&(script.outputImageSpec[script.iOutputImagesCount-1]), sizeof(*script.outputImageSpec));
+ image = &script.outputImageSpec[script.iOutputImagesCount-1];
+ } vars eoln { ; }
+
+optimizeline: PT_TOKEN_OPTIMIZE_LINE PT_TOKEN_SEPARATOR { currentLine=PT_TOKEN_OPTIMIZE_LINE; } vars eoln { ; }
+
+panoline: PT_TOKEN_PANO_LINE PT_TOKEN_SEPARATOR { currentLine=PT_TOKEN_PANO_LINE; } vars eoln { ; }
+
+
+huginVars: huginVar
+ | huginVars PT_TOKEN_SEPARATOR huginVar
+
+huginVar: PT_TOKEN_HUGIN_KEYWORD PT_TOKEN_NUMBER
+ {
+ // The tokens include the = at the end
+ // we could do a substr, but there is no real value on that
+ if (strcmp(PT_AUTO_CENTER_CROP_ST "=", $1) == 0) {
+ autoCenterCrop = lroundf($2);
+ } else if (strcmp(PT_CROP_FACTOR_ST "=" , $1) == 0) {
+ cropFactor = $2;
+ } else {
+ panoScriptParserError(1,"Warning: invalid variable %s found in Hugin image line. Ignored...\n", $1);
+ }
+ }
+
+vars: var
+ | vars PT_TOKEN_SEPARATOR var
+
+/* a variable can be a cropping one (with 4 parms), a one-parm one, a reference to another variable, or finally, a name
+ only */
+var: varcropping | varparameter | varreference | varonly
+
+varsparms: varparameter
+ | varsparms PT_TOKEN_SEPARATOR varparameter
+
+
+
+ /* Rule for input image field references <var>=<index> */
+varreference: PT_TOKEN_KEYWORD PT_TOKEN_REFERENCE PT_TOKEN_NUMBER
+ {
+ int imageRef = lroundf($3) + 1;
+
+ DEBUG_1("Reading varreference");
+
+ switch (currentLine) {
+ case PT_TOKEN_INPUT_LINE:
+ switch ($1) {
+ case 'v':
+ image->fHorFOVIndex = imageRef;
+ break;
+ case 'y':
+ image->yawIndex = imageRef;
+ break;
+ case 'p':
+ image->pitchIndex = imageRef;
+ break;
+ case 'r':
+ image->rollIndex = imageRef;
+ break;
+ case 'a':
+ case 'b':
+ case 'c':
+ case 'd':
+ case 'e':
+ image->coefIndex[$1-'a'] = imageRef;
+ break;
+ case 'g':
+ image->coefIndex[5] = imageRef;
+ break;
+ case 't':
+ image->coefIndex[6] = imageRef;
+ break;
+ case 'R': // This is a hugin Ra,Rb, ...Re
+ // This is a hack. $1 is referenced as a char, but the next character is the
+ // a,b,c,d,e so let us get at it
+ {
+ char *temp = &$1;
+ temp++;
+ switch (*temp) {
+ case 'a':
+ case 'b':
+ case 'c':
+ case 'd':
+ case 'e':
+ image->responseCurveCoefIndex[(*temp)-'a'] = imageRef;
+ break;
+ default:
+ panoScriptParserError(1,"Invalid variable name R[%c] in image line...\n", *temp);
+ return -1;
+ }
+ }
+ break;
+ case 'V': // This is a hugin Va, Vb, Vc, Vd, Vx, Vy
+ // This is a hack. $1 is referenced as a char, but the next character is the
+ // a,b,c,d,e so let us get at it
+ {
+ char *temp = &$1;
+ temp++;
+ switch (*temp) {
+ case 'a':
+ case 'b':
+ case 'c':
+ case 'd':
+ image->vignettingCorrectionCoefIndex[(*temp)-'a'] = imageRef;
+ break;
+ case 'x':
+ case 'y':
+ image->vignettingCorrectionCoefIndex[(*temp)-'x'+4] = imageRef;
+ break;
+ default:
+ panoScriptParserError(1,"Invalid variable name V[%c] in image line...\n", *temp);
+ return -1;
+ }
+ }
+ break;
+ default:
+ panoScriptParserError(1,"Invalid variable name [%c=] in input line.\n", $1);
+ return -1;
+ break;
+ }
+ break;
+ default:
+ panoScriptParserError(1,"Error Not handled 3 [%c]\n", $1);
+ return -1;
+ }
+ }
+
+ /* Rule for [CS]<x>,<x>,<x>,<x> */
+varcropping: PT_TOKEN_CROPPING PT_TOKEN_NUMBER PT_TOKEN_COMMA PT_TOKEN_NUMBER PT_TOKEN_COMMA PT_TOKEN_NUMBER PT_TOKEN_COMMA PT_TOKEN_NUMBER
+ {
+ switch (currentLine) {
+ case PT_TOKEN_OUTPUT_LINE:
+ case PT_TOKEN_INPUT_LINE:
+ switch ($1) {
+ case 'C':
+ case 'S':
+ image->cropType = $1;
+ image->cropArea[0] = lroundf($2);
+ image->cropArea[1] = lroundf($4);
+ image->cropArea[2] = lroundf($6);
+ image->cropArea[3] = lroundf($8);
+ break;
+ default:
+ panoScriptParserError(1,"Invalid variable name- [%c] in image line\n", $1);
+ return -1;
+ }
+ break;
+ default:
+ panoScriptParserError(1,"Error Not handled 3\n");
+ return -1;
+ }
+ }
+
+/*
+ Rules for <variable><parameter>
+ */
+varparameter: PT_TOKEN_KEYWORD PT_TOKEN_STRING
+ {
+
+ DEBUG_2("Token %s", $2);
+
+ /* Processing of string variables */
+ switch (currentLine) {
+ case PT_TOKEN_PANO_LINE:
+ switch ($1) {
+ case 'f':
+ ParserStringCopy(&script.pano.projectionName, $2);
+ break;
+ case 'n':
+ ParserStringCopy(&script.pano.outputFormat, $2);
+ break;
+ case 'P':
+ ParserStringCopy(&script.pano.projectionParmsString, $2);
+ break;
+ case 'T':
+ ParserStringCopy(&script.pano.bitDepthOutput, $2);
+ default:
+ panoScriptParserError(1,"Invalid variable name [%c] in pano line\n", $1);
+ return -1;
+ }
+ break;
+ case PT_TOKEN_OUTPUT_LINE:
+ case PT_TOKEN_INPUT_LINE:
+ switch ($1) {
+ case 'n':
+ ParserStringCopy(&image->name, $2);
+ break;
+ default:
+ panoScriptParserError(1,"Invalid variable name [%c] in image line...\n", $1);
+ return -1;
+ }
+ break;
+ default:
+ panoScriptParserError(1,"Error Not handled case [%c]\n", $1);
+ return -1;
+ }
+ }
+ | PT_TOKEN_KEYWORD PT_TOKEN_NUMBER
+ {
+ /* Processing of int variables */
+ switch (currentLine) {
+ case PT_TOKEN_HUGIN_OPTIONS_LINE:
+ switch ($1) {
+ case 'r':
+ script.optimize.optimizeReferenceImage = lround($2);
+ break;
+ case 'e':
+ script.optimize.blendMode = lround($2);
+ break;
+ default:
+ panoScriptParserError(1, "Invalid variable name [%c] in hugin options line.\n", $1);
+ return -1;
+ break;
+ }
+ break;
+ case PT_TOKEN_CONTROL_PT_LINE:
+ switch ($1) {
+ case 'n':
+ ctrlPoint->iImage1 = lround($2);
+ break;
+ case 'N':
+ ctrlPoint->iImage2 = lround($2);
+ break;
+ case 'x':
+ ctrlPoint->p1.x = $2;
+ break;
+ case 'y':
+ ctrlPoint->p1.y = $2;
+ break;
+ case 'X':
+ ctrlPoint->p2.x = $2;
+ break;
+ case 'Y':
+ ctrlPoint->p2.y = $2;
+ break;
+ case 't':
+ ctrlPoint->type = $2;
+ break;
+ default:
+ panoScriptParserError(1, "Invalid variable name [%c] in control point line.\n", $1);
+ return -1;
+ break;
+ }
+ break;
+ case PT_TOKEN_MORPH_PT_LINE:
+ switch ($1) {
+ case 'i':
+ morphPoint->iImage = lround($2);
+ break;
+ case 'x':
+ morphPoint->p1.x = $2;
+ break;
+ case 'y':
+ morphPoint->p1.y = $2;
+ break;
+ case 'X':
+ morphPoint->p2.x = $2;
+ break;
+ case 'Y':
+ morphPoint->p2.y = $2;
+ break;
+ default:
+ panoScriptParserError(1, "Invalid variable name [%c] in morph line.\n", $1);
+ return -1;
+ break;
+ }
+ break;
+ case PT_TOKEN_PANO_LINE:
+ switch ($1) {
+ case 'w':
+ script.pano.width = lroundf($2);
+ break;
+ case 'h':
+ script.pano.height = lroundf($2);
+ break;
+ case 'f':
+ script.pano.projection = lroundf($2);
+ break;
+ case 'v':
+ script.pano.fHorFOV = $2;
+ break;
+ case 'E':
+ script.pano.exposureValue = $2;
+ break;
+ case 'R':
+ script.pano.dynamicRangeMode = lroundf($2);
+ break;
+ default:
+ panoScriptParserError(1,"Error Invalid variable name [%c] in pano line\n", $1);
+ return -1;
+ }
+ break;
+ case PT_TOKEN_OUTPUT_LINE:
+ case PT_TOKEN_INPUT_LINE:
+ switch ($1) {
+ case 'w':
+ image->width = lroundf($2);
+ break;
+ case 'h':
+ image->height = lroundf($2);
+ break;
+ case 'f':
+ image->projection = lroundf($2);
+ break;
+ case 'v':
+ image->fHorFOV = $2;
+ break;
+ case 'y':
+ image->yaw = $2;
+ break;
+ case 'p':
+ image->pitch = $2;
+ break;
+ case 'r':
+ image->roll = $2;
+ break;
+ case 'a':
+ case 'b':
+ case 'c':
+ case 'd':
+ case 'e':
+ image->coef[$1-'a'] = $2;
+ break;
+ case 'g':
+ image->coef[5] = $2;
+ break;
+ case 't':
+ image->coef[6] = $2;
+ break;
+ case 'u':
+ image->featherSize = lroundf($2);
+ break;
+ case 'm':
+ panoScriptParserError(1,"Warning: Option %c in image line deprecated. Ignored...\n", $1);
+ break;
+ case 'R': // This is a hugin Ry, Ra,Rb, ...Re
+ // This is a hack. $1 is referenced as a char, but the next character is the
+ // a,b,c,d,e so let us get at it
+ {
+ char *temp = &$1;
+ temp++;
+ switch (*temp) {
+ case 'y':
+ image->responseCurveType = lroundf($2);
+ break;
+ case 'a':
+ case 'b':
+ case 'c':
+ case 'd':
+ case 'e':
+ image->responseCurveCoef[(*temp)-'a'] = $2;
+ break;
+ default:
+ panoScriptParserError(1,"Invalid variable name R[%c] in image line...\n", *temp);
+ return -1;
+ }
+ }
+ break;
+ case 'E':
+ {
+ char *temp = &$1;
+ temp++;
+ if (strcmp(temp, "ev") == 0) {
+ image->imageEV = $2;
+ } else if (strcmp(temp, "r") == 0) {
+ image->whiteBalanceFactorRed = $2;
+ } else if (strcmp(temp, "b") == 0) {
+ image->whiteBalanceFactorBlue = $2;
+ } else {
+ panoScriptParserError(1,"Invalid variable name E[%c] in image line...\n", *temp);
+ }
+ }
+ break;
+ case 'V': // This is a hugin Va, Vb, Vc, Vd, Vx, Vy
+ // This is a hack. $1 is referenced as a char, but the next character is the
+ // a,b,c,d,e so let us get at it
+ {
+ char *temp = &$1;
+ temp++;
+ switch (*temp) {
+ case 'm':
+ image->vignettingCorrectionMode = lroundf($2);
+ break;
+ case 'a':
+ case 'b':
+ case 'c':
+ case 'd':
+ image->vignettingCorrectionCoef[(*temp)-'a'] = $2;
+ break;
+ case 'x':
+ case 'y':
+ image->vignettingCorrectionCoef[(*temp)-'x'+4] = $2;
+ break;
+ default:
+ panoScriptParserError(1,"Invalid variable name V[%c] in image line...\n", *temp);
+ return -1;
+ }
+ }
+ break;
+ default:
+ panoScriptParserError(1,"Invalid variable name [%c] in image line...\n", $1);
+ return -1;
+ }
+ break;
+ case PT_TOKEN_OPTIMIZE_LINE:
+ switch ($1) {
+ case 'g':
+ script.optimize.fGamma = $2;
+ if (script.optimize.fGamma <= 0.0) {
+ panoScriptParserError(1,"Invalid value for gamma %f. Must be bigger than zero\n", script.optimize.fGamma);
+ }
+ break;
+ case 'i':
+ script.optimize.interpolator = lroundf($2);
+ // should we verify its value here?
+ break;
+ case 'f':
+ script.optimize.fastFT = lroundf($2);
+ break;
+ case 'm':
+ script.optimize.huberEstimator = $2;
+ break;
+ case 'p':
+ script.optimize.photometricHuberSigma = $2;
+ break;
+ default:
+ panoScriptParserError(1,"Invalid variable name [%c] in optimize line\n", $1);
+ return -1;
+ }
+ break;
+ default:
+ panoScriptParserError(1,"Error. Not handled (token int [%c])\n", $1);
+ return -1;
+ }
+ }
+
+
+varonly: PT_TOKEN_KEYWORD
+ {
+ switch (currentLine) {
+ case PT_TOKEN_PANO_LINE:
+ switch ($1) {
+ case 'T':
+ ParserStringCopy(&script.pano.bitDepthOutput, "");
+ break;
+ default:
+ panoScriptParserError(1,"Invalid variable name [%c] in pano line\n", $1);
+ return -1;
+ }
+ break;
+ case PT_TOKEN_OUTPUT_LINE:
+ case PT_TOKEN_INPUT_LINE:
+ switch ($1) {
+ default:
+ panoScriptParserError(1,"Invalid variable name [%c] in image line....\n", $1);
+ return -1;
+ }
+ break;
+ default:
+ panoScriptParserError(1,"Error Not handled 3\n");
+ return -1;
+ }
+ }
+
+
+
+
+%%
diff -r 000000000000 -r 7c5f0a3fa0fe src/parser/scanner.l
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/parser/scanner.l Tue Aug 26 05:44:10 2008 +0000
@@ -0,0 +1,310 @@
+/*
+ * scanner.h
+ *
+ * Copyright Daniel M. German
+ *
+ * April 2007
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ *
+ * Author: Daniel M German dmgerman at uvic doooot ca
+ *
+ * This lex input file implements the panotools and hugin input scripts
+ *
+ * It ignores 'v' and 'c' lines:
+ *
+ * in 'i' lines it ignores 'K' and 'V' variables which are unique to hugin
+ *
+ */
+
+%option noyywrap
+
+%{
+/* need this for the call to atof() below */
+#include <math.h>
+#include <string.h>
+#include "tparser.h"
+#include "tparserprivate.h"
+#include "parser.h"
+
+char strBuffer[PT_TOKEN_MAX_LEN+1];
+char *strBuffer_ptr;
+
+double ptTokenInt;
+double ptTokenFloat;
+char ptTokenLineType;
+int inVariable = 0;
+
+#define YY_INPUT(buf,result,max_size) {\
+ result = panoScriptScannerGetNextChar(buf, max_size); \
+ if ( result <= 0 ) \
+ result = YY_NULL; \
+ }
+
+%}
+
+DIGIT [0-9]
+LINETYPE [a-zA-Z]
+ID [a-zA-Z]
+
+%x str
+%x parm
+%x hugin
+
+
+%%
+
+-?{DIGIT}+ {
+ /* printf( "An integer: %s (%d)\n", yytext, atoi( yytext ) );*/
+ panoScriptScannerTokenBegin(yytext);
+ yylval.fVal = atof( yytext );
+ return PT_TOKEN_NUMBER;
+ }
+
+-?{DIGIT}+"."{DIGIT}* {
+ /*printf( "A float: %s (%g)\n", yytext, atof( yytext ) );*/
+ panoScriptScannerTokenBegin(yytext);
+ yylval.fVal = atof( yytext );
+ return PT_TOKEN_NUMBER;
+ }
+
+^[ \t]*\n { /* Ignore empty lines */
+ inVariable = 0;
+ }
+
+
+[ \t]*\n { /* END OF LINE is an important marker */
+ /*printf( "End of line: %s\n", yytext );*/
+ panoScriptScannerTokenBegin(yytext);
+ return PT_TOKEN_EOL;
+ }
+
+<<EOF>> {
+ panoScriptScannerTokenBegin(yytext);
+ return PT_TOKEN_EOF;
+ }
+
+
+ /* Tokens to ignore */
+
+^v.*\n { ; } /* Ignore v lines TODO XXXXXXXXXXXX*/
+
+ /* Hugin specific variables. When they are supported it would
+ be easier to generate a new type of token for them. For the
+ time being just ignore them */
+
+
+[K][0-9A-Za-z.=-]+[ \t]* { panoScriptScannerTokenBegin(yytext); } /* ignore K parameters */
+
+
+ /* These are the types of lines supported */
+^o {
+ panoScriptScannerTokenBegin(yytext);
+ return PT_TOKEN_OUTPUT_LINE;
+ }
+
+^i {
+ panoScriptScannerTokenBegin(yytext);
+ return PT_TOKEN_INPUT_LINE;
+ }
+
+^p {
+ panoScriptScannerTokenBegin(yytext);
+ return PT_TOKEN_PANO_LINE;
+ }
+
+^m {
+ panoScriptScannerTokenBegin(yytext);
+ return PT_TOKEN_OPTIMIZE_LINE;
+ }
+
+^"#hugin_options" {
+ panoScriptScannerTokenBegin(yytext);
+ return PT_TOKEN_HUGIN_OPTIONS_LINE;
+ }
+
+^"#-hugin" {
+ panoScriptScannerTokenBegin(yytext);
+ BEGIN(hugin);
+ return PT_TOKEN_HUGIN_LINE;
+ }
+
+<hugin>[ \t]+ { /*printf("skypping separator\n"); */
+ panoScriptScannerTokenBegin(yytext);
+ inVariable = 0;
+ return PT_TOKEN_SEPARATOR;
+ }
+
+
+<hugin>{ID}+= {
+ panoScriptScannerTokenBegin(yytext);
+ strncpy(yylval.strVal, yytext, PT_TOKEN_MAX_LEN);
+ return PT_TOKEN_HUGIN_KEYWORD;
+ }
+
+<hugin>[ \t]*\n {
+ BEGIN(INITIAL);
+ return PT_TOKEN_EOL;
+ }
+
+<hugin>-?{DIGIT}+ {
+ /* printf( "An integer: %s (%d)\n", yytext, atoi( yytext ) );*/
+ panoScriptScannerTokenBegin(yytext);
+ yylval.fVal = atof( yytext );
+ return PT_TOKEN_NUMBER;
+ }
+
+<hugin>-?{DIGIT}+"."{DIGIT}* {
+ /*printf( "A float: %s (%g)\n", yytext, atof( yytext ) );*/
+ panoScriptScannerTokenBegin(yytext);
+ yylval.fVal = atof( yytext );
+ return PT_TOKEN_NUMBER;
+ }
+
+
+
+^c {
+ panoScriptScannerTokenBegin(yytext);
+ return PT_TOKEN_CONTROL_PT_LINE;
+ }
+
+^C {
+ panoScriptScannerTokenBegin(yytext);
+ return PT_TOKEN_MORPH_PT_LINE;
+ }
+
+
+ /*********************************/
+
+"," {
+ panoScriptScannerTokenBegin(yytext);
+ return PT_TOKEN_COMMA; }
+
+E[erb]v? { /* Hugin defines these variables in the i line */
+ panoScriptScannerTokenBegin(yytext);
+ strncpy(yylval.strVal, yytext, PT_TOKEN_MAX_LEN);
+ return PT_TOKEN_KEYWORD;
+ }
+
+V[mabcdxy] { /* Hugin defines these variables in the i line */
+ panoScriptScannerTokenBegin(yytext);
+ strncpy(yylval.strVal, yytext, PT_TOKEN_MAX_LEN);
+ return PT_TOKEN_KEYWORD;
+ }
+
+
+
+R[abcde] { /* Hugin defines these variables in the i line */
+ panoScriptScannerTokenBegin(yytext);
+ strncpy(yylval.strVal, yytext, PT_TOKEN_MAX_LEN);
+ return PT_TOKEN_KEYWORD;
+ }
+
+
+[CS] {
+ /* These are the C and S parameters that contain multiple values */
+ strncpy(yylval.strVal, yytext, PT_TOKEN_MAX_LEN);
+ return PT_TOKEN_CROPPING;
+ }
+
+{ID} {
+ /*printf( "An identifier: %s\n", yytext );*/
+ if (!inVariable) {
+ inVariable = 1;
+ panoScriptScannerTokenBegin(yytext);
+ strncpy(yylval.strVal, yytext, PT_TOKEN_MAX_LEN);
+ return PT_TOKEN_KEYWORD;
+ } else {
+ /* Sometimes this correponds to the first char of
+ a parameter without quotes */
+ BEGIN(parm);
+ strncpy(strBuffer, yytext, PT_TOKEN_MAX_LEN);
+ }
+ }
+
+<parm>[0-9a-zA-Z]+ {
+ /* Read the rest of the parameter */
+ BEGIN(INITIAL);
+ inVariable = 0;
+ strncat(strBuffer, yytext, PT_TOKEN_MAX_LEN -1);
+ strncpy(yylval.strVal, strBuffer, PT_TOKEN_MAX_LEN);
+ return PT_TOKEN_STRING;
+ }
+
+
+[ \t]+ { /*printf("skypping separator\n"); */
+ panoScriptScannerTokenBegin(yytext);
+ inVariable = 0;
+ return PT_TOKEN_SEPARATOR;
+ }
+
+
+= {
+ panoScriptScannerTokenBegin(yytext);
+ return PT_TOKEN_REFERENCE; }
+
+
+"# ".+\n /* eat up comments */
+ {
+ ;
+ }
+
+\" {
+ panoScriptScannerTokenBegin(yytext);
+ strBuffer_ptr = strBuffer; BEGIN(str);
+ //printf("Beginning of string\n");
+ }
+
+<str>\" { /* saw closing quote - all done */
+ BEGIN(INITIAL);
+ *strBuffer_ptr = '\0';
+ /* return string constant token type and
+ * value to parser
+ */
+ // printf("A string %s\n", strBuffer);
+ strncpy(yylval.strVal, strBuffer, PT_TOKEN_MAX_LEN);
+ return PT_TOKEN_STRING;
+ }
+
+<str>\n {
+ /* error - unterminated string constant */
+ /* generate error message */
+ panoScriptParserError(1,"non-terminated string: %s\n", yytext );
+ return -0;
+ }
+
+<str>\\n *strBuffer_ptr++ = '\n';
+<str>\\t *strBuffer_ptr++ = '\t';
+<str>\\r *strBuffer_ptr++ = '\r';
+<str>\\b *strBuffer_ptr++ = '\b';
+<str>\\f *strBuffer_ptr++ = '\f';
+
+<str>\\(.|\n) *strBuffer_ptr++ = yytext[1];
+
+<str>[^\\\n\"]+ {
+ int currentLen = strlen(strBuffer);
+ char *yptr = yytext;
+ while ( *yptr && ++currentLen < PT_TOKEN_MAX_LEN)
+ *strBuffer_ptr++ = *yptr++;
+ }
+
+. {
+ panoScriptParserError(1,"Unrecognized character: %s\n", yytext );
+ return PT_TOKEN_ERROR;
+ }
+
+%%
+
diff -r 000000000000 -r 7c5f0a3fa0fe src/parser/testparser.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/parser/testparser.c Tue Aug 26 05:44:10 2008 +0000
@@ -0,0 +1,70 @@
+/*
+ * tparser.c
+ *
+ * Copyright Daniel M. German
+ *
+ * April 2007
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ *
+ * Author: Daniel M German dmgerman at uvic doooot ca
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdarg.h>
+#include <assert.h>
+
+#include "tparser.h"
+
+
+int main(int argc, char *argv[])
+{
+ int i;
+
+ pt_script script;
+
+ printf("Testing parser for panotools and hugin files\n");
+
+ panoScriptParserSetDefaults(&script);
+
+ if (panoScriptParse(argv[1], FALSE, &script) == NULL) {
+ printf("Parsing error.\n");
+ } else {
+
+
+ if (!panoScriptDeReferenceVariables(&script)) {
+ printf("Unable to de-reference all variable\n");
+ }
+
+ printf("\n\n-----------------Finished parsing\nValues after dereferencing\n\n");
+
+ panoScriptDump(&script);
+
+
+ /*
+ printf("Printing after variables are dereferrenced\n");
+
+ panoScriptDump(&script);
+ */
+ panoScriptParserDispose(&script);
+ }
+
+ return 0;
+}
diff -r 000000000000 -r 7c5f0a3fa0fe src/parser/tparser.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/parser/tparser.c Tue Aug 26 05:44:10 2008 +0000
@@ -0,0 +1,854 @@
+/*
+ * tparser.c
+ *
+ * Copyright Daniel M. German
+ *
+ * April 2007
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ *
+ * Author: Daniel M German dmgerman at uvic doooot ca
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdarg.h>
+#include <assert.h>
+
+#include "tparser.h"
+#include "tparserprivate.h"
+#include "parser.h"
+#include "tparserdebug.h"
+
+int yyparse(void) ;
+
+int debug;
+
+extern char *yytext;
+
+extern pt_script script;
+
+static FILE *file = NULL;
+static int eof = 0;
+static int nRow = 0;
+static int nBuffer = 0;
+static int lBuffer = 0;
+static int nTokenStart = 0;
+static int nTokenLength = 0;
+static int nTokenNextStart = 0;
+static int lMaxBuffer = PARSER_MAX_LINE;
+static char buffer[PARSER_MAX_LINE+1];
+
+
+char panoScriptParserDumpChar(char c)
+{
+ if ( isprint(c) )
+ return c;
+ return '@';
+}
+
+void panoScriptParserDumpRow(void)
+{
+ fprintf(stdout, "%6d |%.*s", nRow, lBuffer, buffer);
+}
+
+
+/* Display parsing error, including the current line and a pointer to the error token */
+
+void panoScriptParserError(int showLine, char const *errorstring, ...)
+{
+ static char errmsg[1000];
+ va_list args;
+
+ int start=nTokenStart;
+ int end=start + nTokenLength - 1;
+ int i;
+
+ DEBUG_1("Enterting panoscriptparserror\n");
+
+ panoScriptParserDumpRow();
+
+ if ( eof ) {
+ fprintf(stdout, " !");
+ for (i=0; i<lBuffer; i++)
+ fprintf(stdout, ".");
+ fprintf(stdout, "^-EOF\n");
+ } else {
+ fprintf(stdout, " !");
+ for (i=1; i<start; i++)
+ fprintf(stdout, ".");
+ for (i=start; i<=end; i++)
+ fprintf(stdout, "^");
+ fprintf(stdout, " at line %d column %d\n", nRow, start);
+ }
+
+ /* print it using variable arguments -----------------------------*/
+ va_start(args, errorstring);
+ vsprintf(errmsg, errorstring, args);
+ va_end(args);
+
+ fprintf(stdout, "%s\n", errmsg);
+
+ // exit
+}
+
+
+int panoScriptScannerGetNextLine(void)
+{
+ char *p;
+
+ nBuffer = 0;
+ nTokenStart = -1;
+ nTokenNextStart = 1;
+ eof = FALSE;
+
+ p = fgets(buffer, lMaxBuffer, file);
+ if ( p == NULL ) {
+ if ( ferror(file) )
+ return -1;
+ eof = TRUE;
+ return 1;
+ }
+
+ nRow += 1;
+ lBuffer = strlen(buffer);
+
+ return 0;
+}
+
+// THis is the function that lex will use to read the next character
+int panoScriptScannerGetNextChar(char *b, int maxBuffer)
+{
+ int frc;
+
+ if ( eof )
+ return 0;
+
+ // read next line if at the end of the current
+ while ( nBuffer >= lBuffer ) {
+ frc = panoScriptScannerGetNextLine();
+ if ( frc != 0 )
+ return 0;
+ }
+
+ // ok, return character
+ b[0] = buffer[nBuffer];
+ nBuffer += 1;
+
+ if ( debug )
+ printf("GetNextChar() => '%c'0x%02x at %d\n",
+ panoScriptParserDumpChar(b[0]), b[0], nBuffer);
+ return b[0]==0?0:1;
+}
+
+
+void panoScriptScannerTokenBegin(char *t)
+{
+ // REcord where a token begins
+ nTokenStart = nTokenNextStart;
+ nTokenLength = strlen(t);
+ nTokenNextStart = nBuffer; // + 1;
+}
+
+
+void yyerror (char const *st)
+{
+ panoScriptParserError(1, st);
+}
+
+// Reallocs ptr by size, count is the variable with the current number of records allocated
+// actual data is in 1000
+// array located at 20 contains 1000
+// ptr has value 20
+// *ptr is 1000
+
+void *panoScriptReAlloc(char **ptr, int size, int *count)
+{
+ char *temp;
+
+ (*count)++;
+ *ptr = realloc(*ptr, *count * size);
+ if (ptr == NULL) {
+ yyerror("Not enough memory");
+ return NULL;
+ }
+ // point to the newly allocated record
+ temp = (char*)*ptr;
+ temp+= size * ((*count)-1);
+ // clear the area
+ bzero(temp, size);
+ return temp;
+}
+
+#ifdef delete
+void *panoScriptReAllocI(pt_script_image **ptr, int size, int *count)
+{
+ char *temp = NULL;
+
+ printf("Before ptr %x *ptr %x\n", ptr, *ptr);
+ printf("return temp %x *size %d, count %d\n", temp, size, *count);
+
+ (*count)++;
+
+ *ptr = realloc(*ptr, (*count) * size);
+ if (ptr == NULL) {
+ yyerror("Not enough memory");
+ return NULL;
+ }
+ // point to the newly allocated record
+ temp = (char*)*ptr;
+
+ printf("To resize count %d, %d\n", *count, (size * ((*count)-1)));
+ temp += size * ((*count)-1);
+ // clear the area
+ bzero(temp, size);
+
+ printf("After ptr %x *ptr %x\n", ptr, *ptr);
+ printf("return temp %x *size %d, count %d\n", temp, size, *count);
+ return temp;
+}
+#endif
+
+/*
+ * dump a control point
+ */
+void panoParserDumpCtrlPoint(pt_script_ctrl_point *ctrlPoint)
+{
+ printf(" image1 %-5d (%6.1f,%6.1f) image2 %-5d (%6.1f,%6.1f) type %d\n",
+ ctrlPoint->iImage1,
+ ctrlPoint->p1.x,
+ ctrlPoint->p1.y,
+ ctrlPoint->iImage2,
+ ctrlPoint->p2.x,
+ ctrlPoint->p2.y,
+ ctrlPoint->type
+ );
+}
+
+/*
+ * dump a control point
+ */
+void panoParserDumpMorphPoint(pt_script_morph_point *ctrlPoint)
+{
+ printf(" image %-5d (%6.1f,%6.1f) to (%6.1f,%6.1f)\n",
+ ctrlPoint->iImage,
+ ctrlPoint->p1.x,
+ ctrlPoint->p1.y,
+ ctrlPoint->p2.x,
+ ctrlPoint->p2.y
+ );
+}
+
+
+/*
+ Dump all information we know about a particular image
+*/
+void panoParserDumpImage(pt_script_image *output)
+{
+ int i;
+ pt_script_morph_point *morphPoint;
+
+ printf(" projection %d\n", output->projection);
+ printf(" width, height %dx%d ", output->width, output->height);
+ printf(" fHorFOV %f\n", output->fHorFOV);
+ printf(" yaw %f ", output->yaw);
+ printf(" pitch %f ", output->pitch);
+ printf(" roll %f ", output->roll);
+
+ printf(" a %f", output->coef[0]);
+ printf(" b %f", output->coef[1]);
+ printf(" c %f", output->coef[2]);
+ printf(" d %f", output->coef[3]);
+ printf(" e %f", output->coef[4]);
+ printf(" g %f", output->coef[5]);
+ printf(" t %f\n", output->coef[6]);
+
+
+ printf("Other parameters.............\n");
+ printf(" name %s\n", output->name);
+ printf(" cropType %c ", output->cropType);
+ printf(" cropArea %i,%i,%i,%i ",
+ output->cropArea[0],
+ output->cropArea[1],
+ output->cropArea[2],
+ output->cropArea[3]);
+ printf(" morphToFit %d", output->morphToFit);
+ printf(" feather size %d", output->featherSize);
+
+ printf("\nHugin parameters\n");
+
+ printf(" autoCenterCrop %d", output->autoCenterCrop);
+ printf(" cropFactor %f", output->cropFactor);
+ printf("\n image ev %f", output->imageEV);
+ printf(" whiteBalanceFactorRed %f", output->whiteBalanceFactorRed);
+ printf(" whiteBalanceFactorBlue %f", output->whiteBalanceFactorBlue);
+ printf("\n responseCurveType %d", output->responseCurveType);
+
+ printf(" Ra %f", output->responseCurveCoef[0]);
+ printf(" Rb %f", output->responseCurveCoef[1]);
+ printf(" Rc %f", output->responseCurveCoef[2]);
+ printf(" Rd %f", output->responseCurveCoef[3]);
+ printf(" Re %f\n", output->responseCurveCoef[4]);
+
+ printf("\n Vignetting Correction Mode %d", output->vignettingCorrectionMode);
+ printf(" Va %f", output->vignettingCorrectionCoef[0]);
+ printf(" Vb %f", output->vignettingCorrectionCoef[1]);
+ printf(" Vc %f", output->vignettingCorrectionCoef[2]);
+ printf(" Vd %f", output->vignettingCorrectionCoef[3]);
+ printf(" Vx %f", output->vignettingCorrectionCoef[4]);
+ printf(" Vy %f", output->vignettingCorrectionCoef[5]);
+
+
+ printf("\nLinked attributes\n");
+ printf(" fHorFOV %d", output->fHorFOVIndex);
+ printf(" yaw %d", output->yawIndex);
+ printf(" pitch %d", output->pitchIndex);
+ printf(" roll %d", output->rollIndex);
+
+ printf("\n a %d", output->coefIndex[0]);
+ printf(" b %d", output->coefIndex[1]);
+ printf(" c %d", output->coefIndex[2]);
+ printf(" d %d", output->coefIndex[3]);
+ printf(" e %d", output->coefIndex[4]);
+ printf(" g %d", output->coefIndex[5]);
+ printf(" t %d\n", output->coefIndex[6]);
+
+ printf("Hugin linked parameters\n");
+
+ printf(" imageEVIndex %d", output->imageEVIndex);
+ printf(" whiteBalanceFactorRedIndex %d", output->whiteBalanceFactorRedIndex);
+ printf(" whiteBalanceFactorBlueIndex %d", output->whiteBalanceFactorBlueIndex);
+
+ printf("\n Va %d", output->vignettingCorrectionCoefIndex[0]);
+ printf(" Vb %d", output->vignettingCorrectionCoefIndex[1]);
+ printf(" Vc %d", output->vignettingCorrectionCoefIndex[2]);
+ printf(" Vd %d", output->vignettingCorrectionCoefIndex[3]);
+ printf(" Vx %d", output->vignettingCorrectionCoefIndex[4]);
+ printf(" Vy %d", output->vignettingCorrectionCoefIndex[5]);
+
+
+ printf("\n Ra %d", output->responseCurveCoefIndex[0]);
+ printf(" Rb %d", output->responseCurveCoefIndex[1]);
+ printf(" Rc %d", output->responseCurveCoefIndex[2]);
+ printf(" Rd %d", output->responseCurveCoefIndex[3]);
+ printf(" Re %d\n", output->responseCurveCoefIndex[4]);
+
+
+ printf("\n");
+
+ printf(" Morphing points count %d\n", output->morphPointsCount);
+
+ for (i=0;i<output->morphPointsCount;i++) {
+ printf(" %-5d ", i);
+ morphPoint = &output->morphPoints[i];
+ panoParserDumpMorphPoint(morphPoint);
+ }
+
+
+}
+
+/*
+ Dump all the script information we have read
+*/
+
+void panoScriptDump(pt_script *script)
+{
+ int i;
+ pt_script_image *output;
+ pt_script_ctrl_point *ctrlPoint;
+ pt_script_morph_point *morphPoint;
+
+ assert(script != NULL);
+
+ printf("Values\n");
+ printf("Pano .................");
+ printf(" width,height %dx%d ", script->pano.width, script->pano.height);
+ printf(" projection %d ", script->pano.projection);
+ printf(" name %s ", script->pano.projectionName);
+ printf(" fHorFOV %f ", script->pano.fHorFOV);
+ printf(" format %s ", script->pano.outputFormat);
+ printf(" bitDepthOutput %s ", script->pano.bitDepthOutput);
+ printf(" proj parms %s\n", script->pano.projectionParmsString);
+ printf(" proj parms count %d\n", script->pano.projectionParmsCount);
+ for (i=0;i<script->pano.projectionParmsCount;i++) {
+ printf(" proj parm %d: %f\n", i, script->pano.projectionParms[i]);
+ }
+
+
+ printf("Optimize ..................");
+ printf(" gamma %f", script->optimize.fGamma);
+ printf(" interpolator %d", script->optimize.interpolator);
+ printf(" fastFT %d ", script->optimize.fastFT);
+ printf(" huber estimator %d \n", script->optimize.huberEstimator);
+
+ printf("Hugin Parameters\n");
+ printf(" dynamic range mode %d", script->pano.dynamicRangeMode);
+ printf(" exposureValue %f", script->pano.exposureValue);
+
+ printf(" photometricHuberSigma %f \n", script->optimize.photometricHuberSigma);
+ printf(" optimize reference image %d \n", script->optimize.optimizeReferenceImage);
+ printf(" blend mode %d \n", script->optimize.blendMode);
+ printf("\n");
+
+
+ printf("Output [%d] images ..................\n", script->iOutputImagesCount);
+
+ for (i=0;i<script->iOutputImagesCount;i++) {
+ output = &script->outputImageSpec[i];
+ printf(" image %d\n", i);
+ panoParserDumpImage(output);
+ }
+ printf("Input [%d] images ..................\n", script->iInputImagesCount);
+
+ for (i=0;i<script->iInputImagesCount;i++) {
+ output = &script->inputImageSpec[i];
+ printf(" image %d\n", i);
+ panoParserDumpImage(output);
+ }
+ printf("Ctrl points [%d] ..................\n", script->iCtrlPointsCount);
+ for (i=0;i<script->iCtrlPointsCount;i++) {
+ ctrlPoint = &script->ctrlPointsSpec[i];
+ printf(" %-5d ", i);
+ panoParserDumpCtrlPoint(ctrlPoint);
+ // panoParserDumpImage(output);
+ }
+#ifdef adfasdf
+ printf("Morphing points [%d] ..................\n", script->iMorphPointsCount);
+ for (i=0;i<script->iMorphPointsCount;i++) {
+ morphPoint = &morphPointsSpec[i];
+ printf(" %-5d ", i);
+ panoParserDumpMorphPoint(morphPoint);
+ }
+#endif
+}
+
+
+/*
+ This function is be called before the parser is used for the first time, and if it wants to be reused.
+ Remember, the parser is not REENTRANT
+ */
+int panoScriptParserReset(void)
+{
+ if (file != NULL) {
+ return FALSE;
+ }
+ /* There should not be anything allocated in script */
+ bzero(&script, sizeof(script));
+
+ //but some parameters are meaningful when zero
+ script.pano.projection = -1;
+ return 1;
+}
+
+/*
+ * Projection parms are outside the scope of the parser. In a way this is good, because they allow the use of
+ * _any_ type of parameters. On the other hand, it is bad because they have to be parsed here instead of the
+ * bison parser.
+ */
+int panoScriptParseProjectionParms()
+{
+ char *ptr;
+ float temp;
+
+ if (script.pano.projectionParmsString != NULL) {
+ // We got parameters which we need to parse
+ ptr = script.pano.projectionParmsString;
+ while (*ptr != '\0') {
+ if (*ptr == ' ' || *ptr == '\t')
+ ptr++;
+ else {
+ if (script.pano.projectionParmsCount >= PANO_PARSER_MAX_PROJECTION_PARMS) {
+ panoScriptParserError(1, "Too many parameters for projection %s (limit is %d)", script.pano.projectionParmsString, PANO_PARSER_MAX_PROJECTION_PARMS);
+ return FALSE;
+ }
+ if (sscanf(ptr, "%f", &temp) != 1) {
+ panoScriptParserError(1, "Illegal floating point number in projection parameters %s", script.pano.projectionParmsString);
+ return FALSE;
+ }
+ script.pano.projectionParms[script.pano.projectionParmsCount] = temp;
+ script.pano.projectionParmsCount++;
+ }
+ }
+ }
+ return TRUE;
+
+}
+
+/*
+ * In some cases variables can point to other variables for their actual parameters. This
+ * function derefereces them.
+ */
+int panoScriptDeReferenceImageVariables(pt_script_image *images, int imagesCount)
+{
+ // if the index != 0 and the indexed image is within bounds, and the indexed image is not a reference...
+ // then set the imageindex, and clear the reference
+#define UNLINK_VARIABLE(i,a,r) (ref= images[i].r-1, \
+ (ref >= 0 && \
+ ref < imagesCount && \
+ images[ref].r == 0 ? \
+ (images[i].a = images[ref].a, \
+ images[i].r = 0, \
+ change=1)\
+ :1\
+ ))
+
+#define UNLINK_VARIABLE2(a,b,c)
+
+ // First unlink the variables that we can
+ int change = 1;
+ int ref;
+ int i,j;
+ // dereferrence until we are done
+ while (change) {
+ change = 0;
+ for (i=0;i<imagesCount;i++) {
+ UNLINK_VARIABLE(i,fHorFOV,fHorFOVIndex);
+ UNLINK_VARIABLE(i,yaw,yawIndex);
+ UNLINK_VARIABLE(i,roll,rollIndex);
+ UNLINK_VARIABLE(i,pitch,pitchIndex);
+ for (j=0;j<PANO_PARSER_COEF_COUNT;j++) {
+ UNLINK_VARIABLE(i,coef[j],coefIndex[j]);
+ }
+ for (j=0;j<PANO_PARSER_RESP_CURVE_COEF_COUNT;j++) {
+ UNLINK_VARIABLE(i,responseCurveCoef[j],responseCurveCoefIndex[j]);
+ }
+ UNLINK_VARIABLE(i,imageEV, imageEVIndex);
+ UNLINK_VARIABLE(i,whiteBalanceFactorRed, whiteBalanceFactorRedIndex);
+ UNLINK_VARIABLE(i,whiteBalanceFactorBlue, whiteBalanceFactorBlueIndex);
+ UNLINK_VARIABLE(i,vignettingCorrectionMode,vignettingCorrectionModeIndex);
+ for (j=0;j<PANO_PARSER_VIGN_COEF_COUNT;j++) {
+ UNLINK_VARIABLE(i,vignettingCorrectionCoef[j],vignettingCorrectionCoefIndex[j]);
+ }
+ }
+ }
+#undef UNLINK_VARIABLE
+ char *names[7] = {"a","b","c","d","e","g","t"};
+
+#define VERIFY_VARIABLE(i,r,m) if (images[i].r!=0) {panoScriptParserError(0, "Unable to resolve reference for variable %s in image %i\n", m, i);return FALSE;}
+
+ // Verify that all links are resolved
+ for (i=0;i<imagesCount;i++) {
+ VERIFY_VARIABLE(i,fHorFOVIndex,"v");
+ VERIFY_VARIABLE(i,yawIndex, "y");
+ VERIFY_VARIABLE(i,rollIndex, "r");
+ VERIFY_VARIABLE(i,pitchIndex, "p");
+ for (j=0;j<PANO_PARSER_COEF_COUNT;j++) {
+ VERIFY_VARIABLE(i,coefIndex[j], names[j]);
+ }
+ for (j=0;j<PANO_PARSER_RESP_CURVE_COEF_COUNT;j++) {
+ VERIFY_VARIABLE(i,responseCurveCoefIndex[j],names[j]);
+ }
+ }
+#undef VERIFY_VARIABLE
+
+ return TRUE;
+}
+
+int panoScriptDeReferenceVariables(pt_script* script)
+{
+ // function that dereferences variables in scripts.
+ if (!panoScriptDeReferenceImageVariables(script->inputImageSpec, script->iInputImagesCount))
+ return FALSE;
+ if (!panoScriptDeReferenceImageVariables(script->outputImageSpec, script->iOutputImagesCount))
+ return FALSE;
+ return TRUE;
+}
+
+
+pt_script *panoScriptParse(char *filename, int dereferenceVariables, pt_script *scriptVar)
+{
+ // filaname: input file
+
+ // deferenceVariables: should references to other variables be resolved?
+
+ DEBUG_1("Starting to parse");
+
+ file = NULL;
+ if (!panoScriptParserReset() ) {
+ // This is really an assertion
+ fprintf(stderr, "This parser is not reentrant");
+ exit(1);
+ }
+ file = fopen(filename, "r");
+ if ( file == NULL ) {
+ return NULL;
+ }
+ if ( panoScriptScannerGetNextLine() == 0 ) {
+ if (yyparse() ==0) {
+ // AT THIS POINT WE HAVE FINISHED PARSING
+
+ // This is the best time to verify input values
+ // and to parse some of the optional parameters
+
+ if (!panoScriptParseProjectionParms() ) {
+ panoScriptParserError(1, "Illegal parameters to projection");
+ goto error;
+ }
+
+ // Deference if required
+ if (dereferenceVariables) {
+ printf("REquestion referencing of variables .......................\n");
+ if (!panoScriptDeReferenceVariables(&script))
+ goto error;
+ }
+ // Just making sure..
+ fclose(file);
+ file = NULL;
+ return scriptVar;
+
+ } else {
+ goto error;
+ }
+ }
+ else {
+ panoScriptParserError(0, "Input file is empty");
+ goto error;
+ }
+ // It should never reach here
+ assert(0);
+ error:
+ if (file != NULL)
+ fclose(file);
+ return NULL;
+
+}
+
+void panoScriptParserSetDefaults(pt_script *ptr)
+{
+ // This is where the defaults will be
+ // At this point. Just clear the data structure.
+ memset(ptr, 0, sizeof(*ptr));
+}
+
+void panoScriptParserDispose(pt_script *ptr)
+{
+ int i;
+ // free all the data structures it uses
+
+#define FREE(a) if ((a) != NULL) free(a)
+
+ // Free pt_script_pano first
+ FREE(ptr->pano.projectionParmsString);
+
+ FREE(ptr->pano.outputFormat);
+ FREE(ptr->pano.bitDepthOutput);
+
+ for (i=0;i<ptr->iOutputImagesCount;i++) {
+ FREE(ptr->outputImageSpec[i].name);
+ }
+ for (i=0;i<ptr->iInputImagesCount;i++) {
+ FREE(ptr->inputImageSpec[i].name);
+ FREE(ptr->inputImageSpec[i].morphPoints);
+ }
+ FREE(ptr->outputImageSpec);
+ FREE(ptr->inputImageSpec);
+ FREE(morphPointsSpec);
+ FREE(ptr->ctrlPointsSpec);
+
+#undef FREE
+ // clear the data structure
+ memset(ptr, 0, sizeof(*ptr));
+}
+
+// ACCESSORS
+
+float panoScriptGetImageCoefA(pt_script_image *pImage)
+{
+ assert(pImage != NULL);
+ return pImage->coef[0];
+}
+
+float panoScriptGetImageCoefB(pt_script_image *pImage)
+{
+ assert(pImage != NULL);
+ return pImage->coef[1];
+}
+
+float panoScriptGetImageCoefC(pt_script_image *pImage)
+{
+ assert(pImage != NULL);
+ return pImage->coef[2];
+}
+
+float panoScriptGetImageCoefD(pt_script_image *pImage)
+{
+ assert(pImage != NULL);
+ return pImage->coef[3];
+}
+
+float panoScriptGetImageCoefE(pt_script_image *pImage)
+{
+ assert(pImage != NULL);
+ return pImage->coef[4];
+}
+
+float panoScriptGetImageSheerX(pt_script_image *pImage)
+{
+ assert(pImage != NULL);
+ return pImage->coef[5];
+}
+
+float panoScriptGetImageSheerY(pt_script_image *pImage)
+{
+ assert(pImage != NULL);
+ return pImage->coef[6];
+}
+
+int panoScriptGetImageCropType(pt_script_image *pImage)
+{
+ assert(pImage != NULL);
+ return pImage->cropType;
+}
+
+
+int panoScriptGetImageMorphToFit(pt_script_image *pImage)
+{
+ assert(pImage != NULL);
+ return pImage->morphToFit;
+}
+
+
+int panoScriptGetInputImagesCount(pt_script *script)
+{
+ assert(script != NULL);
+ return script->iInputImagesCount;
+}
+
+
+int panoScriptGetOutputImagesCount(pt_script *script)
+{
+ assert(script != NULL);
+ return script->iOutputImagesCount;
+}
+
+pt_script_image *panoScriptGetInputImage(pt_script *script, int i)
+{
+ assert(script != NULL);
+ if (i > panoScriptGetInputImagesCount(script)) {
+ return NULL;
+ }
+ return &(script->inputImageSpec[i]);
+}
+
+pt_script_image *panoScriptGetOutputImage(pt_script *script, int i)
+{
+ assert(script != NULL);
+ if (i > panoScriptGetOutputImagesCount(script)) {
+ printf("NONE********\n");
+ return NULL;
+ }
+ return &(script->outputImageSpec[i]);
+}
+
+int panoScriptGetPanoProjection(pt_script *script)
+{
+ return script->pano.projection;
+}
+
+int panoScriptGetPanoWidth(pt_script *script)
+{
+ return script->pano.width;
+}
+
+int panoScriptGetPanoHeight(pt_script *script)
+{
+ return script->pano.height;
+}
+
+float panoScriptGetPanoHFOV(pt_script *script)
+{
+ return script->pano.fHorFOV;
+}
+
+float panoScriptGetPanoParmsCount(pt_script *script)
+{
+ return script->pano.projectionParmsCount;
+}
+
+float panoScriptGetPanoParm(pt_script *script, int index)
+{
+ assert(index < PANO_PARSER_MAX_PROJECTION_PARMS);
+ return script->pano.projectionParms[index];
+}
+
+char *panoScriptGetPanoOutputFormat(pt_script *script)
+{
+ return script->pano.outputFormat;
+}
+
+int panoScriptGetImageProjection(pt_script_image *pImage)
+{
+ assert(pImage!= NULL);
+ return pImage->projection;
+}
+
+char *panoScriptGetName(pt_script_image *pImage)
+{
+ assert(pImage!= NULL);
+ return pImage->name;
+}
+
+
+
+float panoScriptGetImageHFOV(pt_script_image *pImage)
+{
+ assert(pImage!= NULL);
+ return pImage->fHorFOV;
+}
+
+float panoScriptGetImagePitch(pt_script_image *pImage)
+{
+ assert(pImage!= NULL);
+ return pImage->pitch;
+}
+float panoScriptGetImageYaw(pt_script_image *pImage)
+{
+ assert(pImage!= NULL);
+ return pImage->yaw;
+}
+float panoScriptGetImageRoll(pt_script_image *pImage)
+{
+ assert(pImage!= NULL);
+ return pImage->roll;
+}
+
+char *panoScriptGetInputFileNameOfImage(pt_script* script,int index)
+{
+ pt_script_image *pImage;
+ if (index < panoScriptGetInputImagesCount(script)) {
+ pImage = panoScriptGetInputImage(script, index);
+ assert(pImage != NULL);
+ return panoScriptGetName(pImage);
+
+ } else
+ return NULL;
+}
+
+
+char *panoScriptGetOutputFileNameOfImage(pt_script* script,int index)
+{
+ pt_script_image *pImage;
+ if (index < panoScriptGetOutputImagesCount(script)) {
+ pImage = panoScriptGetOutputImage(script, index);
+ assert(pImage != NULL);
+ return panoScriptGetName(pImage);
+
+ } else
+ return NULL;
+}
diff -r 000000000000 -r 7c5f0a3fa0fe src/parser/tparser.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/parser/tparser.h Tue Aug 26 05:44:10 2008 +0000
@@ -0,0 +1,213 @@
+/*
+ * tparser.h
+ *
+ * Copyright Daniel M. German
+ *
+ * April 2007
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ *
+ * Author: Daniel M German dmgerman at uvic doooot ca
+ *
+ */
+
+#ifndef __TPARSER_H__
+#define __TPARSER_H__
+
+
+/* Maximum size for an input token */
+#define PARSER_MAX_LINE 1000
+#define PT_TOKEN_MAX_LEN PARSER_MAX_LINE
+
+#define PANO_PARSER_MAX_PROJECTION_PARMS 10
+/*
+ Data structure where the entire input file will be read
+*/
+
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+
+#define PANO_PARSER_COEF_COUNT 7
+#define PANO_PARSER_RESP_CURVE_COEF_COUNT 5
+#define PANO_PARSER_VIGN_COEF_COUNT 6
+
+typedef struct {
+ double x;
+ double y;
+} pt_point;
+
+typedef struct {
+ int iImage;
+ pt_point p1;
+ pt_point p2;
+} pt_script_morph_point;
+
+typedef struct {
+ int iImage1;
+ int iImage2;
+ pt_point p1;
+ pt_point p2;
+ int type;
+} pt_script_ctrl_point;
+
+typedef struct {
+ int width;
+ int height;
+ int projection;
+ int projectionParmsCount;
+ float projectionParms[PANO_PARSER_MAX_PROJECTION_PARMS];
+ char *projectionParmsString;
+ char *projectionName;
+ float fHorFOV;
+ char *outputFormat; // n : file format of output
+
+ // Hugin parameters
+ int dynamicRangeMode; // R[01] 0 -> LDR; 1 -> HDR
+ char *bitDepthOutput; // T bitdepth of output images, possible values are
+ //XXX TO BE IMPLEMENTED
+ float exposureValue; // E exposure value of final panorama
+} pt_script_pano;
+
+typedef struct {
+ int projection;
+ int width;
+ int height;
+ float fHorFOV;
+ float yaw;
+ float pitch;
+ float roll;
+
+ int featherSize;
+ float coef[PANO_PARSER_COEF_COUNT]; // a, b, c, d, e, g, t
+
+
+ // These are hugin parameters
+ int autoCenterCrop;
+ float cropFactor;
+
+ // Exposure related
+ float imageEV; // Exposure value of image Eev
+ float whiteBalanceFactorRed; // Er
+ float whiteBalanceFactorBlue; // Eb
+
+ int responseCurveType; // Ry 0 -> EMoR, 1 -> linear
+ float responseCurveCoef[PANO_PARSER_RESP_CURVE_COEF_COUNT]; // R[abcde]
+
+ int vignettingCorrectionMode; // Vm
+ float vignettingCorrectionCoef[PANO_PARSER_VIGN_COEF_COUNT]; // V[abcdxy]
+
+ char *name;
+ char cropType ; // it can be 'S' or 'C'
+ int cropArea[PANO_PARSER_COEF_COUNT]; // the rectangle to crop to
+ int morphToFit; // true if morph to fit
+ // pointers to variable if they are used.
+ // For the sake of simplicity they start at 1, if they are zero they are unused
+ int fHorFOVIndex;
+ int yawIndex;
+ int pitchIndex;
+ int rollIndex;
+ int coefIndex[PANO_PARSER_COEF_COUNT]; // a, b, c, d, e , g, t
+
+ // hugin indexes for de-referencing
+
+ int imageEVIndex; //Exposure value of image
+ int whiteBalanceFactorRedIndex; // Er
+ int whiteBalanceFactorBlueIndex; // Eb
+ int vignettingCorrectionModeIndex; // Vm
+ int vignettingCorrectionCoefIndex[PANO_PARSER_VIGN_COEF_COUNT]; // V[abcdxy]
+
+ int responseCurveCoefIndex[PANO_PARSER_RESP_CURVE_COEF_COUNT]; // R[abcde]
+
+ // Morphing Points
+ int morphPointsCount;
+ pt_script_morph_point *morphPoints;
+} pt_script_image;
+
+
+typedef struct {
+ float fGamma;
+ int interpolator;
+ int fastFT;
+ int huberEstimator;
+ float photometricHuberSigma;
+ int optimizeReferenceImage;
+ int blendMode;
+} pt_script_optimize;
+
+typedef struct {
+ pt_script_pano pano;
+ int iInputImagesCount;
+ pt_script_image *inputImageSpec;
+ int iOutputImagesCount;
+ pt_script_image *outputImageSpec;
+ int iMorphPointsCount;
+ pt_script_optimize optimize;
+ int iCtrlPointsCount;
+ pt_script_ctrl_point *ctrlPointsSpec;
+} pt_script;
+
+
+
+void panoScriptParserSetDefaults(pt_script *ptr);
+pt_script *panoScriptParse(char *, int , pt_script *);
+void panoScriptParserDispose(pt_script *ptr);
+void panoScriptDump(pt_script *script);
+
+
+// Accessors to the data structures above...
+// they are the preferred way to access the data in them
+
+float panoScriptGetImageCoefA(pt_script_image *pImage);
+float panoScriptGetImageCoefB(pt_script_image *pImage);
+float panoScriptGetImageCoefC(pt_script_image *pImage);
+float panoScriptGetImageCoefD(pt_script_image *pImage);
+float panoScriptGetImageCoefE(pt_script_image *pImage);
+float panoScriptGetImageSheerX(pt_script_image *pImage);
+float panoScriptGetImageSheerY(pt_script_image *pImage);
+int panoScriptGetImageCropType(pt_script_image *pImage);
+int panoScriptGetImageMorphToFit(pt_script_image *pImage);
+int panoScriptGetImageProjection(pt_script_image *pImage);
+float panoScriptGetImageHFOV(pt_script_image *pImage);
+float panoScriptGetImagePitch(pt_script_image *pImage);
+float panoScriptGetImageYaw(pt_script_image *pImage);
+float panoScriptGetImageRoll(pt_script_image *pImage);
+char *panoScriptGetName(pt_script_image *pImage);
+
+int panoScriptGetInputImagesCount(pt_script *script);
+int panoScriptGetOutputImagesCount(pt_script *script);
+pt_script_image *panoScriptGetInputImage(pt_script *script, int i);
+pt_script_image *panoScriptGetOutputImage(pt_script *script, int i);
+int panoScriptGetPanoProjection(pt_script *script);
+int panoScriptGetPanoWidth(pt_script *script);
+int panoScriptGetPanoHeight(pt_script *script);
+float panoScriptGetPanoHFOV(pt_script *script);
+float panoScriptGetPanoParmsCount(pt_script *script);
+float panoScriptGetPanoParm(pt_script *script, int index);
+char *panoScriptGetPanoOutputFormat(pt_script *script);
+int panoScriptDeReferenceVariables(pt_script* script);
+char *panoScriptGetInputFileNameOfImage(pt_script* script,int index);
+char *panoScriptGetOutputFileNameOfImage(pt_script* script,int index);
+void panoParserDispose(pt_script **scriptVar);
+
+
+
+#endif
+
diff -r 000000000000 -r 7c5f0a3fa0fe src/parser/tparserdebug.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/parser/tparserdebug.h Tue Aug 26 05:44:10 2008 +0000
@@ -0,0 +1,38 @@
+/*
+ * tparserdebug.h
+ *
+ * Copyright Daniel M. German
+ *
+ * April 2007
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ *
+ * Author: Daniel M German dmgerman at uvic doooot ca
+ *
+ */
+#ifndef __TPARSERDEBUG_H__
+
+#define __TPARSERDEBUG_H__
+
+#ifdef YYDEBUG
+#define DEBUG_1(a) fprintf(stderr, #a "\n", a);
+#define DEBUG_2(a,b) fprintf(stderr, #a "\n", b);
+#else
+#define DEBUG_1(a)
+#define DEBUG_2(a,b)
+#endif
+
+#endif
diff -r 000000000000 -r 7c5f0a3fa0fe src/parser/tparserprivate.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/parser/tparserprivate.h Tue Aug 26 05:44:10 2008 +0000
@@ -0,0 +1,41 @@
+/*
+ * tparserprivate.h
+ *
+ * Copyright Daniel M. German
+ *
+ * April 2007
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ *
+ * Author: Daniel M German dmgerman at uvic doooot ca
+ *
+ */
+
+// Defines that are not to be made public outside the parser
+
+#ifndef __TPARSER_PUBLIC_H__
+#define __TPARSER_PUBLIC_H__
+
+static pt_script_morph_point *morphPointsSpec = NULL;
+
+void TokenBegin(char *t) ;
+int panoScriptScannerGetNextChar(char *b, int maxBuffer) ;
+void panoScriptScannerTokenBegin(char *t) ;
+void panoScriptParserError(int showLine, char const *errorstring, ...) ;
+void *panoScriptReAlloc(char **ptr, int size, int *count);
+
+
+#endif
diff -r 000000000000 -r 7c5f0a3fa0fe src/projections/AUTHORS
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/projections/AUTHORS Tue Aug 26 05:44:10 2008 +0000
@@ -0,0 +1,1 @@
+Daniel M. German - http://turingmachine.org/
diff -r 000000000000 -r 7c5f0a3fa0fe src/projections/COPYING
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/projections/COPYING Tue Aug 26 05:44:10 2008 +0000
@@ -0,0 +1,340 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff -r 000000000000 -r 7c5f0a3fa0fe src/projections/README.txt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/projections/README.txt Tue Aug 26 05:44:10 2008 +0000
@@ -0,0 +1,46 @@
+This is the first iteration of the library. At this point I am not
+sure what the best API is, so it might evolve in the future.
+
+I strongly recomment that you look at the *.h file (which is the
+public API). Start with projections.h.
+
+----------------------------------------------------------------------
+projection_type
+
+There are structs (such as extern projection_type
+projAzimPerspective;) that mimic objects. They contain pointers to the
+functions that implement the projection. They also contain any
+information regarding the projection.
+
+----------------------------------------------------------------------
+projection_params
+
+projection_params defines the particular "instance" of a projection to
+be computed. A forward projection transforms from the given projection
+to equirectangular/polar, and inverse computes from
+equirectangular/polar to cartesian.
+
+
+typedef struct {
+ double scale;
+ int tesselate;
+ void *projection;
+} projection_parms;
+
+
+The computations are done assuming a normalized sphere of radious 1,
+This is where "scale" comes into place. scale is a double that
+converts this unitary sphere to the correct size. The first task is to
+compute the scale. TODO: implement a function to calculate the scale
+for every projection.
+
+Tesselate is used to determine if the projection should repeat to fill
+the entire area of the result area. For example, if the Azimuthal
+equal area does not fill the entire output rectangle. If tesselation
+is false, then the region outside its circle will be undefined. If the
+tesselation is true, then the area is defined and correspones to
+"wrapping" around the sphere. Tesselation is undefined for projections
+with an infinite projections (such as stereographic, perspective,
+mercator).
+
+
diff -r 000000000000 -r 7c5f0a3fa0fe src/projections/TODO
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/projections/TODO Tue Aug 26 05:44:10 2008 +0000
@@ -0,0 +1,31 @@
+----------------------------------------------------------------------
+Projections to be implemented:
+
+Cyl:
+ Transverse mercator
+
+Azim:
+ Lambert azimuthal
+ orthographic
+
+PseudoCyl:
+ sinusoidal
+
+Conic:
+ albers
+
+Other:
+ architectural
+ peirce
+ adams
+
+----------------------------------------------------------------------
+
+I need to add a function to each projection that computes the scale
+based upon the current size of the image to project.
+
+----------------------------------------------------------------------
+Create a test suite for the projections.
+
+-----------------------------------------------------------------------
+
diff -r 000000000000 -r 7c5f0a3fa0fe src/projections/projazimuthals.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/projections/projazimuthals.c Tue Aug 26 05:44:10 2008 +0000
@@ -0,0 +1,611 @@
+/*
+ * Copyright Daniel M. German
+ *
+ * April 2007
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ *
+ * Author: Daniel M German dmgerman at uvic doooot ca
+ *
+ */
+#include <math.h>
+#include <assert.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+
+#include "projections.h"
+#include "projazimuthals.h"
+
+projection_type projAzimEquiDistant = {
+ .name = "Azimuthal Equi Distant",
+ .fForward = projAzimEquiDistantFor,
+ .fForwardX = projAzimEquiDistantForX,
+ .fForwardY = projAzimEquiDistantForY,
+
+ .fInverse = projAzimEquiDistantInv,
+ .fInversePhi = projAzimEquiDistantInvPhi,
+ .fInverseLambda = projAzimEquiDistantInvLambda,
+
+ .fDefinedAtPolar = projDefinedFullSpherePolar,
+ .fDefinedAtCart = projAzimEquiDistantDefinedCart,
+
+ .maxVFOV = M_PI/2,
+ .maxHFOV = M_PI,
+
+ .numberParameters = 0
+};
+
+
+
+//;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+// We first define the Azimuthal Equi Distant
+// Which is equivalent to a fisheye lens
+
+
+// is the projectino defined at this cartisian point?
+int projAzimEquiDistantDefinedCart(double x, double y, projection_parms *params)
+{
+ x /= params->scale;
+ y /= params->scale;
+
+ return hypot(x,y) <= 1.0;
+}
+
+
+// Forward
+
+
+
+double projAzimEquiDistantForX(double lambda, double phi, projection_parms *params)
+{
+ double cos_phi;
+ double k;
+ double c;
+
+ phi /= params->scale;
+ lambda /= params->scale;
+
+ if (phi == 0.0 && lambda == 0.0) {
+ //distance from center is zero. Avoids div by zero below
+ return 0.0;
+ }
+
+ cos_phi = cos(phi);
+
+ c = acos(
+ cos_phi *cos(lambda)
+ );
+
+ k = c /sin(c);
+
+ return params->scale * k * cos_phi * sin (lambda);
+
+}
+
+double projAzimEquiDistantForY(double lambda, double phi, projection_parms *params)
+{
+ double cos_phi;
+ double k;
+ double c;
+
+ phi /= params->scale;
+ lambda /= params->scale;
+
+ if (phi == 0.0 && lambda == 0.0) {
+ //distance from center is zero. Avoids div by zero below
+ return 0.0;
+ }
+
+
+ cos_phi = cos(phi);
+
+ c = acos(
+ cos_phi *cos(lambda)
+ );
+
+
+ k = c /sin(c);
+
+ return params->scale * k * sin(phi);
+
+}
+
+
+
+
+int projAzimEquiDistantFor(double lambda, double phi, double *pX, double *pY, projection_parms *params)
+{
+ double cos_phi;
+ double k;
+ double R_x_K;
+ double c;
+
+ phi /= params->scale;
+ lambda /= params->scale;
+
+ if (phi == 0.0 && lambda == 0.0) {
+ //distance from center is zero. Avoids div by zero below
+ *pX = 0;
+ *pY = 0;
+ return 1;
+ }
+
+ cos_phi = cos(phi);
+
+ c = acos(
+ cos_phi *cos(lambda)
+ );
+
+ k = c /sin(c);
+
+ R_x_K = params->scale * k;
+
+ *pX = R_x_K * cos_phi * sin (lambda);
+ *pY = R_x_K * sin(phi);
+
+ return 1;
+
+}
+
+// Inverse
+
+double projAzimEquiDistantInvPhi(double x, double y, projection_parms* params)
+{
+ double c;
+ double rho;
+ double phi = NAN;
+ double sin_c_over_rho;
+
+ x /= params->scale;
+ y /= params->scale;
+
+ if (x == 0.0 && y == 0.0) {
+ return 0.0;
+ }
+
+ rho = hypot(x,y);
+ c = rho; // c is equal to ro because x,y are now normalized to a radious 1
+ if (!params->tesselate) {
+ // If we do not tesselate, then
+ // if the diagonal is > 1 then we are outside the area of the projection
+ if (rho > 1.0) {
+ return NAN;
+ }
+ }
+
+
+ sin_c_over_rho = sin(c) / rho;
+
+ phi = asin(y * sin_c_over_rho);
+
+ return params->scale * phi;
+}
+
+
+double projAzimEquiDistantInvLambda(double x, double y, projection_parms* params)
+{
+ double c;
+ double rho;
+ double lambda = NAN;
+
+ x /= params->scale;
+ y /= params->scale;
+
+ if (x == 0.0 && y == 0.0) {
+ return 0.0;
+ }
+
+ rho = hypot(x,y);
+
+ c = rho; // c is equal to ro because x,y are now normalized to a radious 1
+ if (!params->tesselate) {
+ // If we do not tesselate, then
+ // if the diagonal is > 1 then we are outside the area of the projection
+ if (rho > 1.0) {
+ return NAN;
+ }
+ }
+
+ lambda = atan2(x * sin(c), rho * cos(c));
+
+ return params->scale * lambda;
+}
+
+int projAzimEquiDistantInv(double x, double y, double *pLambda, double *pPhi, projection_parms* params)
+{
+ double c;
+ double rho;
+ double phi = NAN;
+ double lambda = NAN;
+ double sin_c;
+
+ x /= params->scale;
+ y /= params->scale;
+
+ // When values are _exactly zero_ there is the risk of a NAN in the
+ // atan2 function below
+
+ if (x == 0.0 && y == 0.0) {
+ //distance from center is zero. Avoids div by zero below
+ *pPhi = 0.0;
+ *pLambda = 0.0;
+ return 1;
+ }
+
+ rho = hypot(x,y);
+
+ if (!params->tesselate) {
+ // If we do not tesselate, then
+ // if the diagonal is > 1 then we are outside the area of the projection
+ if (rho > 1.0) {
+ printf("Values %f %f %f\n", x, y, rho);
+ *pLambda = NAN;
+ *pPhi = NAN;
+ return 0;
+ }
+ }
+ c = rho; // c is equal to ro because x,y are now normalized to a radious 1
+
+ // save sin(c) to avoid recomputation
+
+ sin_c = sin(c);
+
+ lambda = atan2(x * sin_c, rho * cos(c));
+
+ phi = asin(y * sin_c / rho);
+
+ *pPhi = params->scale *phi;
+ *pLambda = params->scale *lambda;
+
+
+ return 1;
+}
+
+//;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+//;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+// This is the perspective, gnomonic, rectilinear projection
+
+
+projection_type projAzimPerspective = {
+ .name = "Perspective (Gnonomic, rectilinear)",
+ .fForward = projAzimPerspectiveFor,
+ .fForwardX = projAzimPerspectiveForX,
+ .fForwardY = projAzimPerspectiveForY,
+
+ .fInverse = projAzimPerspectiveInv,
+ .fInversePhi = projAzimPerspectiveInvPhi,
+ .fInverseLambda = projAzimPerspectiveInvLambda,
+
+ .fDefinedAtPolar = projAzimPerspectiveDefinedPolar,
+ .fDefinedAtCart = projAzimPerspectiveDefinedCart,
+
+ .maxVFOV = M_PI/2 - PROJ_ONE_DEGREE,
+ .maxHFOV = M_PI/2 - PROJ_ONE_DEGREE,
+
+ .numberParameters = 0
+};
+
+
+
+
+// is the projection defined at this cartesian point?
+int projAzimPerspectiveDefinedCart(double x, double y, projection_parms *params)
+{
+ // What exactly those that mean for this projection?
+
+ return 0;
+}
+
+// is the projection defined at this polar point?
+int projAzimPerspectiveDefinedPolar(double lambda, double phi, projection_parms *params)
+{
+ // What exactly those that mean for this projection?
+
+ return 0;
+}
+
+
+// Forward
+
+
+double projAzimPerspectiveForX(double lambda, double phi, projection_parms *params)
+{
+ lambda /= params->scale;
+ return params->scale * tan(lambda);
+
+}
+
+double projAzimPerspectiveForY(double lambda, double phi, projection_parms *params)
+{
+ lambda /= params->scale;
+ phi /= params->scale;
+
+ if (lambda == 1.0) {
+ // undefined here
+ // We can't tesselate this projection
+ return NAN;
+ }
+ return params->scale * tan(phi) / cos(lambda);
+}
+
+
+
+
+int projAzimPerspectiveFor(double lambda, double phi, double *pX, double *pY, projection_parms *params)
+{
+ lambda /= params->scale;
+ phi /= params->scale;
+
+ if (lambda == 1.0) {
+
+ // THIS NEEDS MORE WORK
+
+ // undefined here
+ // We can't tesselate
+ *pX = NAN;
+ *pY = NAN;
+ return FALSE;
+ }
+
+ *pX = params->scale * tan(lambda);
+ *pY = params->scale * tan(phi) / cos(lambda);
+ return 1;
+}
+
+// Inverse
+
+double projAzimPerspectiveInvPhi(double x, double y, projection_parms* params)
+{
+ double temp = hypot(params->scale, x );
+
+ if (temp == 0.0) {
+ // the projection is undefined at this point
+ return NAN;
+ }
+
+ return params->scale * atan2 (y, temp);
+
+}
+
+
+double projAzimPerspectiveInvLambda(double x, double y, projection_parms* params)
+{
+ return params->scale * atan2 (x, params->scale);
+}
+
+int projAzimPerspectiveInv(double x, double y, double *pLambda, double *pPhi, projection_parms* params)
+{
+ double temp = hypot(params->scale, x );
+
+ if (temp == 0.0) {
+ // the projection is undefined at this point
+ *pLambda = 0.0;
+ *pPhi = 0.0;
+ return FALSE;
+ }
+ *pPhi = params->scale * atan2 (y, temp);
+ *pLambda = params->scale * atan2 (x, params->scale);
+ return TRUE;
+}
+
+//;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+//;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+// This is the stereographic projection
+
+
+projection_type projAzimStereo = {
+ .name = "Stereographic",
+ .fForward = projAzimStereoFor,
+ .fForwardX = projAzimStereoForX,
+ .fForwardY = projAzimStereoForY,
+
+ .fInverse = projAzimStereoInv,
+ .fInversePhi = projAzimStereoInvPhi,
+ .fInverseLambda = projAzimStereoInvLambda,
+
+ .fDefinedAtPolar = projAzimStereoDefinedPolar,
+ .fDefinedAtCart = projAzimStereoDefinedCart,
+
+ .maxVFOV = M_PI/2 - PROJ_ONE_DEGREE,
+ .maxHFOV = M_PI - PROJ_ONE_DEGREE,
+
+ .numberParameters = 0
+};
+
+
+
+
+// is the projection defined at this cartesian point?
+int projAzimStereoDefinedCart(double x, double y, projection_parms *params)
+{
+ // What exactly those that mean for this projection?
+
+ return 0;
+}
+
+// is the projection defined at this polar point?
+int projAzimStereoDefinedPolar(double lambda, double phi, projection_parms *params)
+{
+ // What exactly those that mean for this projection?
+
+ return 0;
+}
+
+
+// Forward
+
+
+double projAzimStereoForX(double lambda, double phi, projection_parms *params)
+{
+ lambda /= params->scale;
+ phi /= params->scale;
+ double cos_phi = cos(phi);
+ double k;
+
+
+ k = params->scale * 2.0/(1.0 + cos_phi * cos(lambda));
+
+ return k * cos_phi * sin(lambda);
+
+}
+
+double projAzimStereoForY(double lambda, double phi, projection_parms *params)
+{
+ lambda /= params->scale;
+ phi /= params->scale;
+
+ double cos_phi = cos(phi);
+ double k;
+
+ k = params->scale * 2.0/(1.0 + cos_phi * cos(lambda));
+
+ return k* sin(phi);
+
+}
+
+
+
+
+int projAzimStereoFor(double lambda, double phi, double *pX, double *pY, projection_parms *params)
+{
+ lambda /= params->scale;
+ phi /= params->scale;
+ double cos_phi = cos(phi);
+ double k;
+
+
+ k = params->scale * 2.0/(1.0 + cos_phi * cos(lambda));
+
+ *pX = k * cos_phi * sin(lambda);
+ *pY = k* sin(phi);
+
+ return TRUE;
+}
+
+// Inverse
+
+double projAzimStereoInvPhi(double x, double y, projection_parms* params)
+{
+ double rho;
+ double c;
+ double sin_c;
+
+ x /= params->scale;
+ y /= params->scale;
+
+ if (x == 0.0 && y == 0.0) {
+ //distance from center is zero. Avoids div by zero below
+ return 0.0;
+ }
+
+ rho = hypot(x,y);
+
+ c = 2 * atan2(rho , 2);
+
+ sin_c = sin(c);
+
+ return asin(y * sin_c /rho) * params->scale;
+
+}
+
+
+double projAzimStereoInvLambda(double x, double y, projection_parms* params)
+{
+
+ double rho;
+ double c;
+ double sin_c;
+ double cos_c ;
+ double phi;
+
+ x /= params->scale;
+ y /= params->scale;
+
+ if (x == 0.0 && y == 0.0) {
+ //distance from center is zero. Avoids div by zero below
+ return 0.0;
+ }
+
+ rho = hypot(x,y);
+
+ c = 2 * atan2(rho , 2);
+
+ sin_c = sin(c);
+
+ phi = asin(y * sin_c /rho);
+
+ cos_c = cos(c);
+
+ if (cos_c == 0.0) {
+ assert(0);
+ return x * params->scale;
+ } else {
+ return atan2(x * sin_c, rho * cos_c) * params->scale;
+ }
+}
+
+int projAzimStereoInv(double x, double y, double *pLambda, double *pPhi, projection_parms* params)
+{
+
+ double rho;
+ double c;
+ double sin_c;
+ double cos_c ;
+ double phi;
+ double lambda;
+
+ x /= params->scale;
+ y /= params->scale;
+
+ if (x == 0.0 && y == 0.0) {
+ //distance from center is zero. Avoids div by zero below
+ *pPhi = 0.0;
+ *pLambda = 0.0;
+ return 1;
+ }
+
+ rho = hypot(x,y);
+
+ c = 2 * atan2(rho , 2);
+
+ sin_c = sin(c);
+
+ phi = asin(y * sin_c /rho);
+
+ cos_c = cos(c);
+
+ if (cos_c == 0.0) {
+ lambda = x;
+ } else {
+ lambda = atan2(x * sin_c, rho * cos_c) ;
+ }
+ *pLambda = lambda * params->scale;
+
+ *pPhi = phi * params->scale;
+
+ return lambda;
+
+
+}
+
+//;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
diff -r 000000000000 -r 7c5f0a3fa0fe src/projections/projazimuthals.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/projections/projazimuthals.h Tue Aug 26 05:44:10 2008 +0000
@@ -0,0 +1,90 @@
+/*
+ * Copyright Daniel M. German
+ *
+ * April 2007
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ *
+ * Author: Daniel M German dmgerman at uvic doooot ca
+ *
+ */
+
+#ifndef __PROJAZIMUTHALS_H__
+#define __PROJAZIMUTHALS_H__
+
+
+
+
+
+//----------------------------------------------------------------------
+//Equidistant
+extern projection_type projAzimEquiDistant;
+
+int projAzimEquiDistantDefinedCart(double x, double y, projection_parms *params);
+
+//Inverse
+double projAzimEquiDistantInvPhi(double x, double y, projection_parms* params);
+double projAzimEquiDistantInvLambda(double x, double y, projection_parms* params);
+int projAzimEquiDistantInv(double x, double y, double *pLambda, double *pPhi, projection_parms* params);
+
+
+//Forward
+double projAzimEquiDistantForX(double lambda, double phi, projection_parms *params);
+double projAzimEquiDistantForY(double lambda, double phi, projection_parms *params);
+int projAzimEquiDistantFor(double lambda, double phi, double *pX, double *pY, projection_parms *params);
+
+
+//----------------------------------------------------------------------
+// Perspective
+
+extern projection_type projAzimPerspective;
+
+int projAzimPerspectiveDefinedPolar(double lambda, double phi, projection_parms *params);
+int projAzimPerspectiveDefinedCart(double lambda, double phi, projection_parms *params);
+
+// Forward
+double projAzimPerspectiveForX(double lambda, double phi, projection_parms *params);
+double projAzimPerspectiveForY(double lambda, double phi, projection_parms *params);
+int projAzimPerspectiveFor(double lambda, double phi, double *pX, double *pY, projection_parms *params);
+
+
+//Inverse
+double projAzimPerspectiveInvPhi(double x, double y, projection_parms* params);
+double projAzimPerspectiveInvLambda(double x, double y, projection_parms* params);
+int projAzimPerspectiveInv(double x, double y, double *pLambda, double *pPhi, projection_parms* params);
+
+//----------------------------------------------------------------------
+// Stereographic
+extern projection_type projAzimStereo;
+
+int projAzimStereoDefinedCart(double x, double y, projection_parms *params);
+int projAzimStereoDefinedPolar(double lambda, double phi, projection_parms *params);
+
+// Forward
+
+double projAzimStereoForX(double lambda, double phi, projection_parms *params);
+double projAzimStereoForY(double lambda, double phi, projection_parms *params);
+int projAzimStereoFor(double lambda, double phi, double *pX, double *pY, projection_parms *params);
+
+// Inverse
+double projAzimStereoInvPhi(double x, double y, projection_parms* params);
+double projAzimStereoInvLambda(double x, double y, projection_parms* params);
+int projAzimStereoInv(double x, double y, double *pLambda, double *pPhi, projection_parms* params);
+
+
+
+#endif
+
diff -r 000000000000 -r 7c5f0a3fa0fe src/projections/projcylindricals.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/projections/projcylindricals.c Tue Aug 26 05:44:10 2008 +0000
@@ -0,0 +1,513 @@
+/*
+ * Copyright Daniel M. German
+ *
+ * April 2007
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ *
+ * Author: Daniel M German dmgerman at uvic doooot ca
+ *
+ */
+#include <math.h>
+#include <assert.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+
+#include "projections.h"
+#include "projcylindricals.h"
+
+// All cylindrical projections have the same way to compute the
+// horizontal coordinate
+
+double projCylindricalX(double lambda, double phi, projection_parms *params)
+{
+ if (params->tesselate) {
+ return lambda;
+ } else {
+ if (fabs(lambda / params->scale) > M_PI)
+ return NAN;
+ else
+ return lambda;
+ }
+}
+
+double projCylindricalInvLambda(double x, double y, projection_parms* params)
+{
+ if (params->tesselate) {
+ x /= params->scale;
+ x = fmod(x, M_PI);
+ return x * params->scale;
+ } else {
+ return x;
+ }
+}
+
+// Useful for projections defined in the entire sphere
+int projCylindricalDefinedPolarWholeSphere(double lambda, double phi, projection_parms *params)
+{
+ // If tesselatations then return true always
+ if (params->tesselate)
+ return TRUE;
+ else {
+ lambda /= params->scale;
+ phi /= params->scale;
+ return fabs(lambda) <= M_PI && fabs(phi) <= M_PI/2;
+ }
+}
+
+// Useful for projections NOT defined in the entire sphere
+int projCylindricalDefinedPolarOnlyHorizontal(double lambda, double phi, projection_parms *params)
+{
+ // tesselation not meaningful in this projection
+ assert(!params->tesselate);
+
+ lambda /= params->scale;
+ phi /= params->scale;
+ return fabs(lambda) <= M_PI && fabs(phi) < M_PI/2;
+}
+
+int projCylindricalDefinedCartOnlyHorizontal(double x, double y, projection_parms *params)
+{
+ // Well defined for all cylindrical projection, as they are normalized to go from
+ if (params->tesselate)
+ return TRUE;
+ else {
+ x /= params->scale;
+ y /= params->scale;
+ return fabs(x) <= M_PI && fabs(y) < M_PI/2;
+ }
+}
+
+//----------------------------------------------------------------------
+// Mercator
+
+projection_type projCylMercator = {
+ .name = "Mercator",
+ .fForward = projCylMercatorFor,
+ .fForwardX = projCylindricalX,
+ .fForwardY = projCylMercatorForY,
+
+ .fInverse = projCylMercatorInv,
+ .fInversePhi = projCylMercatorInvPhi,
+ .fInverseLambda = projCylindricalInvLambda,
+
+ .fDefinedAtPolar = projCylindricalDefinedPolarOnlyHorizontal,
+ .fDefinedAtCart = projCylindricalDefinedCartOnlyHorizontal,
+
+ .maxVFOV = M_PI/2 - PROJ_ONE_DEGREE,
+ .maxHFOV = M_PI,
+
+ .maxHeight = INFINITY,
+ .maxWidth = M_PI,
+
+ .numberParameters = 0
+};
+
+
+// Forward
+
+
+double projCylMercatorForY(double lambda, double phi, projection_parms *params)
+{
+ phi /= params->scale;
+
+ if (fabs(phi) >= M_PI/2 ||
+ fabs(lambda) > M_PI) {
+ return NAN;
+ }
+
+ return params->scale * log(tan(phi) +1/cos(phi));
+}
+
+
+
+int projCylMercatorFor(double lambda, double phi, double *pX, double *pY, projection_parms *params)
+{
+ phi /= params->scale;
+
+ if (fabs(phi) >= M_PI/2 ||
+ fabs(lambda) > M_PI) {
+ *pX = NAN;
+ *pY = NAN;
+ return FALSE;
+ }
+
+ *pY = params->scale * log(tan(phi) +1/cos(phi));
+ *pX = lambda;
+
+ return TRUE;
+}
+
+// Inverse
+
+double projCylMercatorInvPhi(double x, double y, projection_parms* params)
+{
+ y /= params->scale;
+
+ if (fabs(y) >= M_PI/2 ||
+ fabs(x) > M_PI) {
+ return NAN;
+ }
+
+ return params->scale * atan(sinh(y));
+
+}
+
+
+int projCylMercatorInv(double x, double y, double *pLambda, double *pPhi, projection_parms* params)
+{
+
+ y /= params->scale;
+ assert(params->tesselate == 0);
+
+ if (fabs(y) >= M_PI/2 ||
+ fabs(x) > M_PI) {
+ *pLambda = NAN;
+ *pPhi = NAN;
+ return FALSE;
+ }
+
+ *pLambda = x;
+ *pPhi = params->scale * atan(sinh(y));
+
+ return TRUE;
+
+}
+
+//;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+//----------------------------------------------------------------------
+// CylCentral
+
+projection_type projCylCentral = {
+ .name = "Central Cylindrical",
+ .fForward = projCylCentralFor,
+ .fForwardX = projCylindricalX,
+ .fForwardY = projCylCentralForY,
+
+ .fInverse = projCylCentralInv,
+ .fInversePhi = projCylCentralInvPhi,
+ .fInverseLambda = projCylindricalInvLambda,
+
+ .fDefinedAtPolar = projCylindricalDefinedPolarOnlyHorizontal,
+ .fDefinedAtCart = projCylindricalDefinedCartOnlyHorizontal,
+
+ .maxVFOV = M_PI/2 - PROJ_ONE_DEGREE,
+ .maxHFOV = M_PI,
+ .maxHeight = INFINITY,
+ .maxWidth = M_PI,
+
+ .numberParameters = 0
+};
+
+
+// Forward
+
+
+double projCylCentralForY(double lambda, double phi, projection_parms *params)
+{
+ phi /= params->scale;
+
+ if (fabs(phi) >= M_PI/2)
+ return NAN;
+
+ return params->scale * tan(phi);
+}
+
+
+
+int projCylCentralFor(double lambda, double phi, double *pX, double *pY, projection_parms *params)
+{
+ phi /= params->scale;
+
+ if (fabs(phi) == M_PI/2 ||
+ fabs(lambda) > M_PI) {
+ return FALSE;
+ }
+
+ *pY = params->scale * tan(phi);
+ *pX = lambda;
+
+ return TRUE;
+}
+
+// Inverse
+
+double projCylCentralInvPhi(double x, double y, projection_parms* params)
+{
+ y /= params->scale;
+
+ if (fabs(y) == M_PI/2) {
+ return NAN;
+ }
+
+ return params->scale * atan(y);
+
+}
+
+
+int projCylCentralInv(double x, double y, double *pLambda, double *pPhi, projection_parms* params)
+{
+
+ y /= params->scale;
+ assert(params->tesselate == 0);
+
+ *pLambda = x;
+ if (fabs(y) >= M_PI/2 || fabs(x) > M_PI) {
+ *pPhi = NAN;
+ return FALSE;
+ }
+
+ *pPhi = params->scale * atan(y);
+
+ return TRUE;
+
+}
+
+//;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+//----------------------------------------------------------------------
+// Miller
+
+// printf ("#define PROJ_CYL_MILLER_MAX_HEIGH %60.60e\n", asinh(tan( 0.8 * M_PI/2))/0.8);
+
+#define PROJ_CYL_MILLER_MAX_HEIGH 2.3034125433763907864204156794585287570953369140625
+
+projection_type projCylMiller = {
+ .name = "Miller",
+ .fForward = projCylMillerFor,
+ .fForwardX = projCylindricalX,
+ .fForwardY = projCylMillerForY,
+
+ .fInverse = projCylMillerInv,
+ .fInversePhi = projCylMillerInvPhi,
+ .fInverseLambda = projCylindricalInvLambda,
+
+ .fDefinedAtPolar = projCylindricalDefinedPolarWholeSphere,
+ .fDefinedAtCart = projCylMillerDefinedCart,
+
+ .maxVFOV = M_PI/2,
+ .maxHFOV = M_PI,
+ .maxHeight = PROJ_CYL_MILLER_MAX_HEIGH,
+ .maxWidth = M_PI,
+ .numberParameters = 0
+};
+
+
+int projCylMillerDefinedCart(double x, double y, projection_parms *params)
+{
+ // What exactly those that mean for this projection?
+ if (params->tesselate)
+ return TRUE;
+ else {
+ x /= params->scale;
+ y /= params->scale;
+ return fabs(x) <= M_PI && fabs(y) <= projCylMiller.maxHeight;
+ }
+}
+
+// Forward
+
+double projCylMillerForY(double lambda, double phi, projection_parms *params)
+{
+ phi /= params->scale;
+
+ if (!params->tesselate && fabs(phi) > M_PI/2) {
+ return NAN;
+ }
+
+ return params->scale * log(tan(M_PI/4 +0.4 * phi))/0.8;
+}
+
+
+
+int projCylMillerFor(double lambda, double phi, double *pX, double *pY, projection_parms *params)
+{
+ phi /= params->scale;
+
+ if (!params->tesselate) {
+ if (fabs(phi) > M_PI/2 || fabs(lambda/params->scale) > M_PI) {
+ *pX = NAN;
+ *pY = NAN;
+ return FALSE;
+ }
+ }
+
+ // There are different ways to compute this projection.
+ // Both are accurate
+ *pY = params->scale * log(tan(M_PI/4 +0.4 * phi))/0.8;
+ //*pY = params->scale * asinh(tan( 0.8 * phi))/0.8;
+ *pX = lambda;
+
+ return TRUE;
+}
+
+// Inverse
+
+double projCylMillerInvPhi(double x, double y, projection_parms* params)
+{
+ y /= params->scale;
+
+ if (!params->tesselate && fabs(y) > projCylMiller.maxHeight) {
+ return NAN;
+ }
+
+ return params->scale * 1.25 * atan(sinh(4 * y /5.0));
+
+}
+
+
+int projCylMillerInv(double x, double y, double *pLambda, double *pPhi, projection_parms* params)
+{
+
+ y /= params->scale;
+
+
+ if (!params->tesselate) {
+ if (fabs(y) > projCylMiller.maxHeight ||
+ fabs(x/params->scale) > M_PI) {
+ *pLambda = NAN;
+ *pPhi = NAN;
+ return FALSE;
+ }
+ }
+
+
+ *pLambda = x;
+ // Both have been tested as accurate. I suspect the second
+ // one is more efficient
+ // *pPhi = params->scale * atan(sinh(0.8 * y)) /0.8;
+ *pPhi = params->scale * 2.5 * atan(exp(0.8 * y)) - 5 * M_PI /8;
+
+ return TRUE;
+
+}
+
+//;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+//----------------------------------------------------------------------
+// Lambert
+
+projection_type projCylLambertEqualArea = {
+ .name = "Lambert Cylindrical Equal Area",
+ .fForward = projCylLambertEqualAreaFor,
+ .fForwardX = projCylindricalX,
+ .fForwardY = projCylLambertEqualAreaForY,
+
+ .fInverse = projCylLambertEqualAreaInv,
+ .fInversePhi = projCylLambertEqualAreaInvPhi,
+ .fInverseLambda = projCylindricalInvLambda,
+
+ .fDefinedAtPolar = projCylindricalDefinedPolarWholeSphere,
+ .fDefinedAtCart = projCylLambertEqualAreaDefinedCart,
+
+ .maxVFOV = M_PI/2,
+ .maxHFOV = M_PI,
+
+ .maxHeight = 1.0,
+ .maxWidth = M_PI,
+
+
+ .numberParameters = 0
+};
+
+int projCylLambertEqualAreaDefinedCart(double x, double y, projection_parms *params)
+{
+ // What exactly those that mean for this projection?
+ if (params->tesselate)
+ return TRUE;
+ else {
+ x /= params->scale;
+ y /= params->scale;
+ return fabs(x) <= M_PI && fabs(y) <= projCylMiller.maxHeight;
+ }
+}
+
+
+// Forward
+
+
+double projCylLambertEqualAreaForY(double lambda, double phi, projection_parms *params)
+{
+ phi /= params->scale;
+
+ if (!params->tesselate && fabs(phi) > M_PI/2) {
+ return NAN;
+ }
+
+ return params->scale * sin(phi);
+}
+
+
+
+int projCylLambertEqualAreaFor(double lambda, double phi, double *pX, double *pY, projection_parms *params)
+{
+ phi /= params->scale;
+
+ if (!params->tesselate) {
+ if (fabs(phi) > M_PI/2 ||
+ fabs(lambda/params->scale) > M_PI) {
+ *pX = NAN;
+ *pY = NAN;
+ return FALSE;
+ }
+ }
+
+ *pY = params->scale * sin(phi);
+ *pX = lambda;
+
+ return TRUE;
+}
+
+// Inverse
+
+double projCylLambertEqualAreaInvPhi(double x, double y, projection_parms* params)
+{
+ y /= params->scale;
+
+ if (!params->tesselate && fabs(y) > projCylLambertEqualArea.maxHeight) {
+ return NAN;
+ }
+
+ return params->scale * asin(y);
+
+}
+
+
+int projCylLambertEqualAreaInv(double x, double y, double *pLambda, double *pPhi, projection_parms* params)
+{
+
+ y /= params->scale;
+
+ if (!params->tesselate) {
+ if (fabs(y) > projCylLambertEqualArea.maxHeight || fabs(x/params->scale)> M_PI) {
+ *pLambda = NAN;
+ *pPhi = NAN;
+ return FALSE;
+ }
+ }
+
+ *pLambda = x;
+ *pPhi = params->scale * asin(y);
+
+ return TRUE;
+
+}
+
diff -r 000000000000 -r 7c5f0a3fa0fe src/projections/projcylindricals.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/projections/projcylindricals.h Tue Aug 26 05:44:10 2008 +0000
@@ -0,0 +1,91 @@
+/*
+ * Copyright Daniel M. German
+ *
+ * April 2007
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ *
+ * Author: Daniel M German dmgerman at uvic doooot ca
+ *
+ */
+
+#ifndef __PROJCYLINDRICALS_H__
+#define __PROJCYLINDRICALS_H__
+
+
+//----------------------------------------------------------------------
+//Mercator
+extern projection_type projCylMercator;
+
+//Inverse
+double projCylMercatorInvPhi(double x, double y, projection_parms* params);
+int projCylMercatorInv(double x, double y, double *pLambda, double *pPhi, projection_parms* params);
+
+
+//Forward
+double projCylMercatorForY(double lambda, double phi, projection_parms *params);
+int projCylMercatorFor(double lambda, double phi, double *pX, double *pY, projection_parms *params);
+
+
+//----------------------------------------------------------------------
+// Central cylindrical
+extern projection_type projCylCentral;
+
+//Inverse
+double projCylCentralInvPhi(double x, double y, projection_parms* params);
+int projCylCentralInv(double x, double y, double *pLambda, double *pPhi, projection_parms* params);
+
+
+//Forward
+double projCylCentralForY(double lambda, double phi, projection_parms *params);
+int projCylCentralFor(double lambda, double phi, double *pX, double *pY, projection_parms *params);
+
+
+//----------------------------------------------------------------------
+//Miller
+extern projection_type projCylMiller;
+
+int projCylMillerDefinedCart(double x, double y, projection_parms *params);
+
+//Inverse
+double projCylMillerInvPhi(double x, double y, projection_parms* params);
+int projCylMillerInv(double x, double y, double *pLambda, double *pPhi, projection_parms* params);
+
+
+//Forward
+double projCylMillerForY(double lambda, double phi, projection_parms *params);
+int projCylMillerFor(double lambda, double phi, double *pX, double *pY, projection_parms *params);
+
+//----------------------------------------------------------------------
+// Cylindrical Lambert Equal Area
+extern projection_type projCylLambertEqualArea;
+
+int projCylLambertEqualAreaDefinedCart(double x, double y, projection_parms *params);
+
+
+//Inverse
+double projCylLambertEqualAreaInvPhi(double x, double y, projection_parms* params);
+int projCylLambertEqualAreaInv(double x, double y, double *pLambda, double *pPhi, projection_parms* params);
+
+
+//Forward
+double projCylLambertEqualAreaForY(double lambda, double phi, projection_parms *params);
+int projCylLambertEqualAreaFor(double lambda, double phi, double *pX, double *pY, projection_parms *params);
+
+
+
+#endif
+
diff -r 000000000000 -r 7c5f0a3fa0fe src/projections/projections.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/projections/projections.c Tue Aug 26 05:44:10 2008 +0000
@@ -0,0 +1,47 @@
+/*
+ * Copyright Daniel M. German
+ *
+ * April 2007
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ *
+ * Author: Daniel M German dmgerman at uvic doooot ca
+ *
+ */
+
+#include <math.h>
+
+#include "projections.h"
+#include "projazimuthals.h"
+
+
+//This function determines if a point if defined for polar coordinates.
+// It is expected to be used by projections as a reasonable default
+
+int projDefinedFullSpherePolar(double lambda, double phi, projection_parms* params)
+{
+ lambda /= params->scale;
+ phi /= params->scale;
+
+ return fabs(lambda) <= M_PI &&
+ fabs(phi) <= M_PI;
+}
+
+
+int projDefinedFullSphereCart(double x, double y, projection_parms* params)
+{
+ return 1;
+}
diff -r 000000000000 -r 7c5f0a3fa0fe src/projections/projections.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/projections/projections.h Tue Aug 26 05:44:10 2008 +0000
@@ -0,0 +1,90 @@
+/*
+ * Copyright Daniel M. German
+ *
+ * April 2007
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ *
+ * Author: Daniel M German dmgerman at uvic doooot ca
+ *
+ */
+#ifndef __PROJECTIONS_H__
+
+#define __PROJECTIONS_H__
+
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+
+#define PROJ_ONE_DEGREE (M_PI / 180.0)
+
+
+
+typedef struct {
+ double scale;
+ int tesselate;
+ void *projection;
+} projection_parms;
+
+typedef int (*projectionForwardFunction)(double, double, double*, double*, projection_parms *);
+typedef double (*projectionForwardXFunction)(double, double, projection_parms *);
+typedef double (*projectionForwardYFunction)(double, double, projection_parms *);
+
+typedef int (*projectionInverseFunction)(double, double, double*, double*, projection_parms *);
+typedef double (*projectionInversePhiFunction)(double, double, projection_parms *);
+typedef double (*projectionInverseLambdaFunction)(double, double, projection_parms *);
+
+
+typedef int (*projectionDefinedAt)(double , double , projection_parms* ) ;
+
+
+
+typedef struct {
+ char *name;
+
+ // Functions to compute forward and inverse of the projection
+
+ projectionForwardFunction fForward;
+ projectionForwardXFunction fForwardX;
+ projectionForwardYFunction fForwardY;
+
+ projectionInverseFunction fInverse;
+ projectionInversePhiFunction fInversePhi;
+ projectionInverseLambdaFunction fInverseLambda;
+
+ projectionDefinedAt fDefinedAtPolar; // is a point defined for the projectin given polar coord?
+ projectionDefinedAt fDefinedAtCart; // is a point defined for the projectin given cart coord?
+ int numberParameters; // does the projection take extra parameters?
+ double maxVFOV; // max vertical field of view from center in radians
+ double maxHFOV; // max horizontal field of view from center in radians
+
+ double maxHeight; // the width of the projection, usually one of width
+ double maxWidth; // or height are normalized to PI
+} projection_type;
+
+
+int projDefinedFullSpherePolar(double lambda, double phi, projection_parms* params) ;
+int projDefinedFullSphereCart(double x, double y, projection_parms* params) ;
+
+
+
+
+#endif
diff -r 000000000000 -r 7c5f0a3fa0fe src/vips/CMakeLists.txt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/vips/CMakeLists.txt Tue Aug 26 05:44:10 2008 +0000
@@ -0,0 +1,41 @@
+#include_directories( ${CMAKE_SOURCE_DIR}/src/vips )
+#add_subdirectory(plugTransform)
+#add_subdirectory(plugResample)
+
+# build a shared library (vips plugin)
+ADD_LIBRARY(transform SHARED plug.c transform.c resample.c interpolation.c maskgen.c)
+SET_TARGET_PROPERTIES(transform PROPERTIES SUFFIX ".plg")
+
+# set special compiler flags.
+SET_TARGET_PROPERTIES(transform PROPERTIES COMPILE_FLAGS "${VIPS_CFLAGS_OTHER_STRING}")
+
+# set special linker flags
+SET_TARGET_PROPERTIES(transform PROPERTIES LINK_FLAGS "${VIPS_LDFLAGS_OTHER_STRING}")
+
+#link to the library
+TARGET_LINK_LIBRARIES(transform panoparser pano13 panotoolswrapper ${VIPS_LIBRARIES})
+
+INSTALL(TARGETS transform LIBRARY DESTINATION lib)
+
+
+# set include and library directories
+link_directories( ${VIPS_LIBRARY_DIRS} )
+include_directories( ${VIPS_INCLUDE_DIRS} )
+
+#for testing you probably need some test app too
+ADD_EXECUTABLE(testTmap transmap.c resample.c transform.c interpolation.c maskgen.c)
+
+# set special compiler flags.
+SET_TARGET_PROPERTIES(testTmap PROPERTIES COMPILE_FLAGS "${VIPS_CFLAGS_OTHER_STRING}")
+
+# set special linker flags
+SET_TARGET_PROPERTIES(testTmap PROPERTIES LINK_FLAGS "${VIPS_LDFLAGS_OTHER_STRING}")
+
+#link to the library
+TARGET_LINK_LIBRARIES(testTmap panoparser pano13 panotoolswrapper ${VIPS_LIBRARIES})
+
+
+#add an install target here
+#INSTALL_FILES(...)
+#INSTALL_PROGRAMS(...)
+#INSTALL_TARGET(...)
diff -r 000000000000 -r 7c5f0a3fa0fe src/vips/ChangeLog
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/vips/ChangeLog Tue Aug 26 05:44:10 2008 +0000
@@ -0,0 +1,73 @@
+2007-07-11 Shahid <shahid21st@...>
+
+ * transmap.c - used im_filename_suffix_match
+ * plug.c - Set interpolation type parameter to int
+ * resample.c - now grow the input image in every outer edge and also the input mask. Corrected expand factor of bicubic to 3. Also corrected all rounding by adding a 0.5 factor.
+ * interpolation.c - Shifted the interpolation center pixel according to the interpolation factor before interpolation. Return without doing interpolation if any dependent pixel is not defined valid by the input mask.
+
+2007-07-08 Shahid <shahid21st@...>
+
+ * Added input image mask generation and checking.
+
+2007-07-05 Shahid <shahid21st@...>
+
+ * Changed the panoScriptParse argument to TRUE for correctly dreferencing arguments in transform operation.
+
+2007-07-03 Shahid <shahid21st@...>
+
+ * Fixed mask image output and bicubic interpolation.
+
+2007-07-01 Shahid <shahid21st@...>
+
+ * Added mask image output and bicubic interpolation.
+
+2007-06-29 Shahid <shahid21st@...>
+
+ * Fixed some plugin input, incorporated interpolation type input in resample plugin.
+
+2007-06-28 Shahid <shahid21st@...>
+
+ * Moved all sources in the vips directory, merged changelog and modified CMakeLists.txt accordingly.
+
+2007-06-28 Shahid <shahid21st@...>
+
+ * Fixed some plugin description bug.
+
+2007-06-28 Shahid <shahid21st@...>
+
+ * Fixed some bug in transmap.
+
+2007-06-28 Shahid <shahid21st@...>
+
+ * interpolation.h, interpolation.c : Added bilinear interpolation
+
+2007-06-27 Pablo d'Angelo <pablo.dangelo@...>
+
+ * CMakeLists.txt: use correct compiler and linker flags for VIPS.
+
+2007-06-27 Pablo d'Angelo <pablo.dangelo@...>
+
+ * CMakeLists.txt: use correct compiler and linker flags for VIPS,
+ install final library with .plg suffix
+
+2007-06-27 Shahid <shahid21st@...>
+
+ * transmap.c transform.c transform.h resample.c resample.h: First commit of test file to glue trasnformation and resampling together
+
+2007-06-24 Shahid <shahid21st@...>
+
+ * Changed the plugin style from WIO to PIO.
+
+2007-06-20 Shahid <shahid21st@...>
+
+ * Reduced plugin input from four to two - removed the unnecessary size inputs. Also deleted some unnecessary source lines.
+
+2007-06-20 Shahid <shahid21st@...>
+
+ * plug.c, resample.c, resample.h, CMakeLists.txt, ChangeLog, README: First commit. Implementation of a simple vips plugin to build image fro source image and coordinate image.
+
+2007-06-14 Shahid <shahid21st@...>
+
+ * plug.c, transform.c, transform.h, transform_image_build.c, CMakeLists.txt, ChangeLog, README: First commit. Implementation of a simple vips plugin to build transform image.
+
+
diff -r 000000000000 -r 7c5f0a3fa0fe src/vips/README
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/vips/README Tue Aug 26 05:44:10 2008 +0000
@@ -0,0 +1,1 @@
+To be added soon!
diff -r 000000000000 -r 7c5f0a3fa0fe src/vips/interpolation.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/vips/interpolation.c Tue Aug 26 05:44:10 2008 +0000
@@ -0,0 +1,116 @@
+#include "stdio.h"
+#include "stdlib.h"
+#include <string.h>
+#include <ctype.h>
+#include <stdarg.h>
+#include <assert.h>
+#include <math.h>
+
+#include "interpolation.h"
+
+
+unsigned char linearInterpolation(double d0, double p0, double d1, double p1)
+{
+ return ((unsigned char) ( p0 * d0 + p1 * d1 ));
+}
+
+int billinearInterpolation(unsigned char *q, REGION *reg, REGION *mreg, double px, double py, const int ps)
+{
+ int p00x, p00y, p01x, p01y, p10x, p10y, p11x, p11y, i;
+ double xdis, ydis;
+ unsigned char *p00, *p01, *p10, *p11, a0, a1, *s[4];
+ px += 1.0;
+ py += 1.0;
+
+ p00x = (int) (px+0.5);
+ p00y = (int) (py+0.5);
+ xdis = px - p00x;
+ ydis = py - p00y;
+
+ /*printf("px= %f, py = %f, xdis = %f, ydis = %f\n", px, py, xdis, ydis);*/
+ p01x = p00x + 1;
+ p01y = p00y;
+
+ p10x = p00x;
+ p10y = p00y + 1;
+
+ p11x = p01x;
+ p11y = p10y;
+
+ s[0] = (unsigned char *) IM_REGION_ADDR (mreg, p00x, p00y);
+ s[1] = (unsigned char *) IM_REGION_ADDR (mreg, p01x, p01y);
+ s[2] = (unsigned char *) IM_REGION_ADDR (mreg, p10x, p10y);
+ s[3] = (unsigned char *) IM_REGION_ADDR (mreg, p11x, p11y);
+
+ if(s[0] == 0 || s[1] == 0 || s[2] == 0 || s[3] == 0)
+ return -1;
+ p00 = (unsigned char *) IM_REGION_ADDR (reg, p00x, p00y);
+ p01 = (unsigned char *) IM_REGION_ADDR (reg, p01x, p01y);
+ p10 = (unsigned char *) IM_REGION_ADDR (reg, p10x, p10y);
+ p11 = (unsigned char *) IM_REGION_ADDR (reg, p11x, p11y);
+
+ for(i = 0; i < ps; i++) {
+ /*printf("00= %d\t01= %d\t10= %d\t11= %d\n", p00[i], p01[i], p10[i], p11[i]);*/
+
+ a0 = linearInterpolation(1-xdis, p00[i], xdis, p01[i]);
+ a1 = linearInterpolation(1-xdis, p10[i], xdis, p11[i]);
+ q[i] = linearInterpolation(1-ydis, a0, ydis, a1);
+ /*printf("i = %d, a0 = %d, a1 = %d, q[i] = %d\n", i, a0, a1, q[i]);*/
+ }
+ return 0;
+}
+
+
+
+double cubicInterpolation( double dis, double f0, double f1, double f2, double f3 )
+{
+ return( ( -f0 + f1 - f2 + f3) * (dis*dis*dis)
+ + (2.0*f0 - 2.0*f1 + f2 - f3) * (dis*dis)
+ + ( -f0 + f2 ) * dis
+ + f1 );
+}
+
+
+
+int bicubicInterpolation(unsigned char *q, REGION *reg, REGION *mreg, double px, double py, const int ps)
+{
+ int p00x, p00y, i, j;
+ double xdis, ydis, a0, a1, a2, a3;
+ unsigned char *k[4][4], *s;
+ /*printf("for: px = %f, py = %f\n", px, py); */
+ px += 3.0;
+ py += 3.0;
+ p00x = (int) (px+0.5);
+ p00y = (int) (py+0.5);
+ xdis = fabs(px - p00x);
+ ydis = fabs(py - p00y);
+
+ /*printf("interol need:left = %d\twidth = %d\ttop = %d\theight = %d\n", p00x-1, p00x+2, p00y-1, p00y+2);*/
+
+
+ for(j = 0; j < 4; j++)
+ for(i = 0; i < 4; i++) {
+ s = (unsigned char *) IM_REGION_ADDR (mreg, p00x-1+i, p00y-1+j);
+ if(*s == 255)
+ k[j][i] = (unsigned char *) IM_REGION_ADDR (reg, p00x-1+i, p00y-1+j);
+ else {
+ return -1;
+ }
+ }
+
+ for(i = 0; i < ps; i++) {
+ a0 = cubicInterpolation(xdis, k[0][0][i], k[0][1][i], k[0][2][i], k[0][3][i]);
+ /*printf("for a0: %d -- %d -- %d -- %d == %f\n", k[0][0][i], k[0][1][i], k[0][2][i],
+ k[0][3][i], a0);*/
+ a1 = cubicInterpolation(xdis, k[1][0][i], k[1][1][i], k[1][2][i], k[1][3][i]);
+ a2 = cubicInterpolation(xdis, k[2][0][i], k[2][1][i], k[2][2][i], k[2][3][i]);
+ a3 = cubicInterpolation(xdis, k[3][0][i], k[3][1][i], k[3][2][i], k[3][3][i]);
+
+ q[i] = (unsigned char) cubicInterpolation(ydis, a0, a1, a2, a3);
+ /*printf("for output: %f -- %f -- %f -- %f == %f == %d\n", a0, a1, a2, a3,
+ cubicInterpolation(ydis, a0, a1, a2, a3), q[i]);*/
+ }
+
+ return 0;
+}
+
diff -r 000000000000 -r 7c5f0a3fa0fe src/vips/interpolation.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/vips/interpolation.h Tue Aug 26 05:44:10 2008 +0000
@@ -0,0 +1,16 @@
+#ifndef __INTERPOLATION_H__
+#define __INTERPOLATION_H__
+
+#define DEBUG
+
+#include <vips/vips.h>
+
+#define maxDefined 2
+#define BICUBIC 2
+#define BILLINEAR 1
+#define NN 0
+
+int billinearInterpolation(unsigned char *q, REGION *reg, REGION *mreg, double px, double py, const int ps);
+int bicubicInterpolation(unsigned char *q, REGION *reg, REGION *mreg, double px, double py, const int ps);
+
+#endif
diff -r 000000000000 -r 7c5f0a3fa0fe src/vips/maskgen.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/vips/maskgen.c Tue Aug 26 05:44:10 2008 +0000
@@ -0,0 +1,67 @@
+#include "stdio.h"
+#include "stdlib.h"
+#include <string.h>
+#include <ctype.h>
+#include <stdarg.h>
+#include <assert.h>
+
+#include "maskgen.h"
+
+
+int isFormat(IMAGE *out, const char *fileName, const char *format)
+{
+ /*printf("starting format chk with filename = %s, format = %s\n", fileName, format);*/
+ char *ext, *substr;
+ int i;
+
+ if(!(ext = IM_ARRAY(out, 10, char))) {
+ printf("memeroy allocation error\n");
+ return -1;
+ }
+ substr = IM_ARRAY(out, 10, char);
+
+ substr = strrchr(fileName, '.');
+ for(i = 0; i < strlen(substr)-1; i++) {
+ ext[i] = tolower(substr[i+1]);
+ }
+
+ ext[i] = '\0';
+
+ /*printf("in isFormat: format = %s, ext = %s\n", format, ext);*/
+ i = strcmp(format, ext);
+
+ return i;
+}
+
+
+int circle (IMAGE * out, int w, int h, double x, double y, double r)
+{
+ IMAGE *t[8];
+
+ if (im_open_local_array (out, t, 8, "circle", "p") ||
+ /* Get x/y into t[1] and t[2]
+ */
+ im_make_xy (t[0], w, h) ||
+ im_extract_band (t[0], t[1], 0) || im_extract_band (t[0], t[2], 1) ||
+ /* Shift origin
+ */
+ im_lintra (1.0, t[1], -x, t[3]) || im_lintra (1.0, t[2], -y, t[4]) ||
+ /* Square.
+ */
+ im_multiply (t[3], t[3], t[5]) || im_multiply (t[4], t[4], t[6]) ||
+ /* Add and threshold.
+ */
+ im_add (t[5], t[6], t[7]) || im_lessconst (t[7], out, r * r))
+ return (-1);
+
+ return (0);
+}
+
+
+int makeCircularMask(IMAGE *out, int width, int height, double cx, double cy, double radius)
+{
+ if(circle(out, width, height, cx, cy, radius))
+ return -1;
+
+ return 0;
+}
diff -r 000000000000 -r 7c5f0a3fa0fe src/vips/maskgen.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/vips/maskgen.h Tue Aug 26 05:44:10 2008 +0000
@@ -0,0 +1,27 @@
+#ifndef __MASKGEN_H__
+#define __MASKGEN_H__
+
+#include <vips/vips.h>
+
+/*
+Input mask checking procedure:
+1. detect whether input image is tif or png (In this case they already
+possess a mask.)
+2. if condition 1 is true then extract band no. 4 (let the staring
+band is numbered as 1) as initial input image mask.
+3. if condition 1 is false then create a white image as initial mask
+(by using im_black and im_invert).
+4. Logically And the initial mask obtained either from step 2 or 3
+with the mask obtained from the panotools script - more specifically a
+mask is available if circular crop is mentioned, i.e. if
+pt_transform->crop_circular = 1, then extract crop parameters from
+crop_circular_cx, crop_circular_cy, crop_circular_radius and create
+the circle mask with these parameters using manual circle operation.
+5. Pass the combined input mask to resample operation.
+6. Check the mask along with input image boundary check during resampling.
+*/
+
+int isFormat(IMAGE *out, const char *fileName, const char *format);
+int makeCircularMask(IMAGE *out, int widht, int height, double cx, double cy, double radius);
+
+#endif
diff -r 000000000000 -r 7c5f0a3fa0fe src/vips/plug.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/vips/plug.c Tue Aug 26 05:44:10 2008 +0000
@@ -0,0 +1,99 @@
+#include <stdio.h>
+
+#include <vips/vips.h>
+
+#include "transform.h"
+#include "resample.h"
+
+static int
+transform_image_build_vec( im_object *argv )
+{
+ IMAGE *out;
+ char *transformFile;
+ int i;
+
+ out = argv[0];
+ transformFile = argv[1];
+ i = *((int *) argv[2]);
+
+ if( transform_image( out, transformFile, i) )
+ return( -1 );
+
+ return( 0 );
+}
+
+static im_arg_desc transform_image_build_arg_types[] =
+{
+ IM_OUTPUT_IMAGE( "out" ),
+ IM_INPUT_STRING( "transform" ),
+ IM_INPUT_INT( "image_number" )
+};
+
+static im_function transform_image_build_desc =
+{
+ "transform_image_build", /* Name */
+ "build a transform image", /* Description */
+ IM_FN_PIO, /* Flags */
+ transform_image_build_vec, /* Dispatch function */
+ IM_NUMBER( transform_image_build_arg_types ),/* Size of arg list */
+ transform_image_build_arg_types /* Arg list */
+};
+
+
+
+static int
+output_resample_image_vec( im_object *argv )
+{
+ IMAGE *out, *outMask;
+ char outputImageMask[100];
+ int iType;
+
+ out = argv[2];
+ sprintf(outputImageMask, "%sMask.v", "output");
+ outMask = im_open_local(out, outputImageMask, "w");
+ iType = *((int *) argv[4]);
+
+ if (output_resample_image (argv[0], argv[1], out, outMask, argv[3], iType))
+ error_exit ("unable to run operation");
+
+ return 0;
+}
+
+static im_arg_desc output_resample_image_arg_types[] =
+{
+ IM_INPUT_IMAGE( "coordinate" ),
+ IM_INPUT_IMAGE( "source" ),
+ IM_OUTPUT_IMAGE( "output" ),
+ IM_INPUT_IMAGE( "inputMask" ),
+ IM_INPUT_INT( "interpolation_type" )
+};
+
+static im_function output_resample_image_desc =
+{
+ "output_resample_image", /* Name */
+ "output resample image (interpolation_type: 0 = nearest neighbour, 1 = bilinear, 2 = bicubic)", /* Description */
+ IM_FN_PIO | IM_FN_TRANSFORM, /* Flags */
+ output_resample_image_vec, /* Dispatch function */
+ IM_NUMBER( output_resample_image_arg_types ),/* Size of arg list */
+ output_resample_image_arg_types /* Arg list */
+};
+
+
+
+static im_function *function_list[] =
+{
+ &transform_image_build_desc,
+ &output_resample_image_desc
+};
+
+
+
+/* Define the package_table symbol. This is what VIPS looks for when loading
+ * the plugin.
+ */
+G_MODULE_EXPORT im_package package_table =
+{
+ "transform", /* Package name */
+ IM_NUMBER( function_list ), /* Function list */
+ function_list
+};
diff -r 000000000000 -r 7c5f0a3fa0fe src/vips/resample.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/vips/resample.c Tue Aug 26 05:44:10 2008 +0000
@@ -0,0 +1,304 @@
+#include "stdio.h"
+#include "stdlib.h"
+#include <string.h>
+#include <ctype.h>
+#include <stdarg.h>
+#include <assert.h>
+
+#include "resample.h"
+#include "interpolation.h"
+
+
+int findBoundary(REGION *or, Rect *out, IMAGE *im, int intType)
+{
+ /*printf("in FB\n");*/
+ Rect *in;
+ int le, to, ri, bo, x, y, pxi, pyi, xmax, xmin, ymax, ymin;
+ double *p, py, px;
+
+ in = &or->valid;
+ le = in->left;
+ to = in->top;
+ ri = IM_RECT_RIGHT( in );
+ bo = IM_RECT_BOTTOM( in );
+
+ p = (double *) IM_REGION_ADDR (or, le, to);
+ px = p[0];
+ py = p[1];
+ pxi = (int)(px+0.5);
+ pyi = (int)(py+0.5);
+
+ xmax = pxi; xmin = pxi; ymax = pyi; ymin = pyi;
+ xmax = -1; xmin = im->Xsize-(2*intType); ymax = -1; ymin = im->Ysize-(2*intType);
+
+ /*printf("FB:left = %d\twidth = %d\ttop = %d\theight = %d\n", in->left, in->width, in->top,
+ in->height);*/
+ for( y = to; y < bo; y++ ) {
+ p = (double *) IM_REGION_ADDR (or, le, y);
+
+ for( x = le; x < ri; x++ ) {
+ px = p[0];
+ py = p[1];
+
+ p += 2;
+ pxi = (int)(px+0.5);
+ pyi = (int)(py+0.5);
+
+ if (pxi < (im->Xsize-(2*intType)) && pxi >= 0 && pyi < (im->Ysize-(2*intType)) &&
+ pyi >= 0) {
+
+ if(pxi > xmax)
+ xmax = pxi;
+ if(pyi > ymax)
+ ymax = pyi;
+ if(pxi < xmin)
+ xmin = pxi;
+ if(pyi < ymin)
+ ymin = pyi;
+ }
+ /*else
+ printf("out of bound: px = %f, pxi = %d, py = %f, pyi = %d\n", px, pxi, py, pyi);*/
+ }
+ }
+
+ /*if(xmax == xmin || ymax == ymin) { */
+ if(xmax < xmin || ymax < ymin) {
+ /*printf("xmax = %d, xmin = %d, ymax = %d, ymin = %d\n", xmax, xmin, ymax, ymin);*/
+ return -1;
+ } else {
+ out->top = ymin - 0;
+ out->left = xmin - 0;
+ out->height = ymax + (2*intType) - ymin;
+ out->width = xmax + (2*intType) - xmin;
+ }
+ /*printf("input:left = %d\twidth = %d\ttop = %d\theight = %d\n", out->left, out->width,
+ out->top, out->height);*/
+ return 0;
+}
+
+
+static int
+output_resample_image_gen( REGION *or, REGION **ir, IMAGE **vec, int iType)
+{
+ Rect inRect, *r;
+ int le, to, ri, bo, x, y, pxi, pyi;
+ double *p, px, py;
+ unsigned char *q, *s;
+
+ /*printf("interpolation type: %d, %d\n", iType, intType);*/
+ /*if(iType != 3)
+ return -1;*/
+
+ r = &or->valid;
+ le = r->left;
+ to = r->top;
+ ri = IM_RECT_RIGHT( r );
+ bo = IM_RECT_BOTTOM( r );
+
+ /*printf("output/coordinate:left = %d\twidth = %d\ttop = %d\theight = %d\n", r->left,
+ r->width, r->top, r->height);*/
+
+ if(im_prepare(ir[0], r)) {
+ return -1;
+ }
+
+ if(!findBoundary(ir[0], &inRect, vec[1], iType))
+ if( (im_prepare(ir[1], &inRect)) || (im_prepare(ir[2], &inRect))) {
+ return -1;
+ }
+
+ /*printf("GEN: b4 main loop\n");*/
+ for( y = to; y < bo; y++ ) {
+ p = (double *) IM_REGION_ADDR (ir[0], le, y);
+ int ps = IM_IMAGE_SIZEOF_PEL (vec[1]);
+ q = (unsigned char *) IM_REGION_ADDR (or, le, y);
+
+ for( x = le; x < ri; x++ ) {
+ px = p[0];
+ py = p[1];
+ pxi = (int)(px+0.5);
+ pyi = (int)(py+0.5);
+
+ p += 2;
+ /*s = (unsigned char *) IM_REGION_ADDR (ir[2], (int) (px+0.5), (int) (py+0.5));*/
+
+ if (pxi < (vec[1]->Xsize - 2*iType) && pxi >= 0 &&
+ pyi < (vec[1]->Ysize - 2*iType) && pyi >= 0 /*&& (*s == 255)*/) {
+ switch (iType) {
+ case 0:
+ s = (unsigned char *) IM_REGION_ADDR (ir[2], (int) (px+0.5),
+ (int) (py+0.5));
+ if(*s == 255)
+ memcpy (q, IM_REGION_ADDR (ir[1], (int) (px+0.5), (int) (py+0.5)), ps);
+ else
+ memset (q, 0, ps);
+ break;
+
+ case 1:
+ if(billinearInterpolation(q, ir[1], ir[2], px, py, ps))
+ memset (q, 0, ps);
+ break;
+
+ case 3:
+ if(bicubicInterpolation(q, ir[1], ir[2], px, py, ps))
+ memset (q, 0, ps);
+ break;
+
+ default:
+ printf("Unknown interpolation type\n");
+ return (-1);
+ }
+ } else {
+ memset (q, 0, ps);
+ }
+
+ q += ps;
+ }
+ }
+
+ return( 0 );
+}
+
+
+static int
+output_resample_image_mask_gen( REGION *or, REGION *ir, IMAGE *coordinate)
+{
+ /*printf("start mask gen\n");*/
+ Rect *r;
+ int le, to, ri, bo, x, y;
+ double *p, px, py;
+ unsigned char *q;
+
+ r = &or->valid;
+ le = r->left;
+ to = r->top;
+ ri = IM_RECT_RIGHT( r );
+ bo = IM_RECT_BOTTOM( r );
+
+ /*printf("b4 prepare\n");*/
+ if(im_prepare(ir, r)) {
+ return -1;
+ }
+
+ /*printf("after prepare\n");*/
+ for( y = to; y < bo; y++ ) {
+ p = (double *) IM_REGION_ADDR (ir, le, y);
+ /*printf("b4 outer fill\n");*/
+ q = (unsigned char *) IM_REGION_ADDR (or, le, y);
+
+ for( x = le; x < ri; x++ ) {
+ px = p[0];
+ py = p[1];
+
+ p += 2;
+ /*printf("b4 fill\n");*/
+ if (px < coordinate->Xsize && px >= 0 && py < coordinate->Ysize && py >= 0) {
+ *q = 255;
+ } else {
+ *q = 0;
+ }
+
+ q += 1;
+ }
+ }
+
+ return( 0 );
+}
+
+
+
+int
+output_resample_image (IMAGE * coordinate, IMAGE * in, IMAGE * out, IMAGE *outMask, IMAGE *inMask, int intType)
+{
+ IMAGE **vec, *inXpnd, *inMaskXpnd;
+ int xpndFactor;
+ /*printf("starting output resample image ....\n");*/
+ if(intType > maxDefined) {
+ im_error ("output_resample_image", "undefined interpolation type");
+ return -1;
+ } else {
+ if(intType == BICUBIC)
+ xpndFactor = 3;
+ else
+ xpndFactor = intType;
+ }
+
+ if (im_piocheck (coordinate, out))
+ return -1;
+ if (im_pincheck (in))
+ return -1;
+
+ inXpnd = im_open_local(out, "inXpnd", "p");
+ inMaskXpnd = im_open_local(out, "inMaskXpnd", "p");
+ if (im_poutcheck (inXpnd))
+ return -1;
+
+ printf("b4 embedding - expand factor: %d\n", xpndFactor);
+ if(im_embed( in, inXpnd, 1, xpndFactor, xpndFactor, in->Xsize + (2*xpndFactor),
+ in->Ysize + (2*xpndFactor) ))
+ return (-1);
+ else
+ {
+ printf("embedding successful: new height: %d, new width %d\n", inXpnd->Xsize,
+ inXpnd->Ysize);
+ }
+
+ if(im_embed( inMask, inMaskXpnd, 1, xpndFactor, xpndFactor, inMask->Xsize + (2*xpndFactor),
+ inMask->Ysize + (2*xpndFactor) ))
+ return (-1);
+ else
+ {
+ printf("mask embedding successful: new height: %d, new width %d\n", inMaskXpnd->Xsize,
+ inMaskXpnd->Ysize);
+ }
+ printf("after checking IO\n");
+
+ if (coordinate->Coding != IM_CODING_NONE ||
+ coordinate->Bands != 2 || coordinate->BandFmt != IM_BANDFMT_DOUBLE) {
+ im_error ("output_resample_image", "bad coordinate image");
+ return -1;
+ }
+
+ if (inXpnd->Coding != IM_CODING_NONE || inXpnd->BandFmt != IM_BANDFMT_UCHAR) {
+ im_error ("output_resample_image", "bad input image");
+ return -1;
+ }
+
+ if (im_cp_desc (out, inXpnd))
+ return -1;
+
+ out->Xsize = coordinate->Xsize;
+ out->Ysize = coordinate->Ysize;
+
+ /* preparing mask image headers */
+
+ if( im_poutcheck( outMask ) )
+ return( -1 );
+
+ im_initdesc( outMask, out->Xsize, out->Ysize, 1, IM_BBITS_DOUBLE, IM_BANDFMT_UCHAR,
+ IM_CODING_NONE, IM_TYPE_B_W, 1.0, 1.0, 0, 0 );
+
+ /*printf("b4 calling demand\n");*/
+
+ if( im_demand_hint( out, IM_SMALLTILE, coordinate, inXpnd, inMaskXpnd, NULL ) )
+ return( -1 );
+ if( !(vec = im_allocate_input_array( out, coordinate, inXpnd, inMaskXpnd, NULL )) )
+ return( -1 );
+
+ printf("b4 calling generate function");
+ if( im_generate( out,
+ im_start_many, output_resample_image_gen, im_stop_many, vec, (int *)xpndFactor ) )
+ return( -1 );
+
+ if( im_demand_hint( outMask, IM_SMALLTILE, coordinate, NULL ) )
+ return( -1 );
+
+ /*printf("b4 calling generate function2\n");*/
+ if( im_generate( outMask,
+ im_start_one, output_resample_image_mask_gen, im_stop_one, coordinate, NULL) )
+ return( -1 );
+
+ /*printf("after calling generate function2\n");*/
+ return 0;
+}
+
diff -r 000000000000 -r 7c5f0a3fa0fe src/vips/resample.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/vips/resample.h Tue Aug 26 05:44:10 2008 +0000
@@ -0,0 +1,11 @@
+#ifndef __RESAMPLE_H__
+#define __RESAMPLE_H__
+
+#define DEBUG
+
+#include <vips/vips.h>
+
+int output_resample_image( IMAGE *coordinate, IMAGE *in, IMAGE *out, IMAGE *outMask, IMAGE *inMask, int intType);
+
+
+#endif
diff -r 000000000000 -r 7c5f0a3fa0fe src/vips/test/ChangeLog
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/vips/test/ChangeLog Tue Aug 26 05:44:10 2008 +0000
@@ -0,0 +1,11 @@
+2007-06-22 Shahid <shahid21st@...>
+
+ * testResamplePIO.c: Added test directory to put test program files and also add a file.
+
+2007-06-23 Shahid <shahid21st@...>
+
+ * Corrected some bugs in testResamplePIO.c
+
+2007-06-24 Shahid <shahid21st@...>
+
+ * Using im_start_many and im_stop_many instead of im_start_one and im_stop_one in testResamplePIO.c
diff -r 000000000000 -r 7c5f0a3fa0fe src/vips/test/testResamplePIO.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/vips/test/testResamplePIO.c Tue Aug 26 05:44:10 2008 +0000
@@ -0,0 +1,194 @@
+/* compile with:
+ *
+ * gcc -Wall -g testResample.c `pkg-config vips-7.12 --cflags --libs`
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdarg.h>
+#include <assert.h>
+
+#include <vips/vips.h>
+
+
+int
+findBoundary (REGION * cr, Rect * out, IMAGE * im)
+{
+ Rect *in = &cr->valid;
+ int le = in->left;
+ int to = in->top;
+ int ri = IM_RECT_RIGHT (in);
+ int bo = IM_RECT_BOTTOM (in);
+
+ int x, y, pxi, pyi;
+ int xmax = -1, xmin = 30000, ymax = -1, ymin = 30000;
+
+ for (y = to; y < bo; y++)
+ {
+ double *p = (double *) IM_REGION_ADDR (cr, le, y);
+
+ for (x = le; x < ri; x++)
+ {
+ double px = p[0];
+ double py = p[1];
+
+ p += 2;
+ pxi = (int) px;
+ pyi = (int) py;
+
+ if (pxi < im->Xsize && pxi >= 0 && pyi < im->Ysize && pyi >= 0)
+ {
+ if (pxi > xmax)
+ xmax = pxi;
+ if (pyi > ymax)
+ ymax = pyi;
+ if (pxi < xmin)
+ xmin = pxi;
+ if (pyi < ymin)
+ ymin = pyi;
+ }
+ }
+ }
+
+ out->top = ymin;
+ out->left = xmin;
+ out->height = ymax - ymin;
+ out->width = xmax - xmin;
+ printf ("left = %d\twidth = %d\ttop = %d\theight = %d\n", out->left,
+ out->width, out->top, out->height);
+ return 0;
+}
+
+
+static int
+output_resample_image_gen (REGION * or, REGION ** ir, IMAGE ** vec)
+{
+ Rect *r = &or->valid;
+ Rect inRect;
+ /*REGION *reg; */
+
+ int le = r->left;
+ int to = r->top;
+ int ri = IM_RECT_RIGHT (r);
+ int bo = IM_RECT_BOTTOM (r);
+
+ if (im_prepare (ir[0], r))
+ {
+ return -1;
+ }
+
+ findBoundary (ir[0], &inRect, vec[1]);
+ /*if(!(reg = im_region_create(in)))
+ return -1; */
+
+ if (im_prepare (ir[1], &inRect))
+ {
+ /*im_region_free(reg); */
+ return -1;
+ }
+
+ int x, y;
+
+ for (y = to; y < bo; y++)
+ {
+ double *p = (double *) IM_REGION_ADDR (ir[0], le, y);
+ const int ps = IM_IMAGE_SIZEOF_PEL (vec[1]);
+ unsigned char *q = (unsigned char *) IM_REGION_ADDR (or, le, y);
+
+ for (x = le; x < ri; x++)
+ {
+ double px = p[0];
+ double py = p[1];
+
+ p += 2;
+
+ if (px < vec[1]->Xsize && px >= 0 && py < vec[1]->Ysize && py >= 0)
+ memcpy (q, IM_REGION_ADDR (ir[1], (int) px, (int) py), ps);
+ else
+ memset (q, 0, ps);
+
+ q += ps;
+ }
+ }
+
+ /*im_region_free(reg); */
+ return (0);
+}
+
+
+
+int
+output_resample_image (IMAGE * coordinate, IMAGE * in, IMAGE * out)
+{
+ printf ("starting output resample image ....\n");
+ IMAGE **vec;
+ if (im_piocheck (coordinate, out))
+ return -1;
+ if (im_pincheck (in))
+ return -1;
+ printf ("after checking IO\n");
+
+ if (coordinate->Coding != IM_CODING_NONE ||
+ coordinate->Bands != 2 || coordinate->BandFmt != IM_BANDFMT_DOUBLE)
+ {
+ im_error ("output_resample_image", "bad coordinate image");
+ return -1;
+ }
+
+ if (in->Coding != IM_CODING_NONE || in->BandFmt != IM_BANDFMT_UCHAR)
+ {
+ im_error ("output_resample_image", "bad input image");
+ return -1;
+ }
+
+ if (im_cp_desc (out, in))
+ return -1;
+
+ out->Xsize = coordinate->Xsize;
+ out->Ysize = coordinate->Ysize;
+ printf ("b4 calling demand\n");
+ if (im_demand_hint (out, IM_SMALLTILE, coordinate, in, NULL))
+ return (-1);
+
+ if (!(vec = im_allocate_input_array (out, coordinate, in, NULL)))
+ return (-1);
+
+ printf ("b4 calling generate\n");
+ if (im_generate (out,
+ im_start_many, output_resample_image_gen, im_stop_many,
+ vec, NULL))
+ return (-1);
+
+ return 0;
+}
+
+
+int
+main (int argc, char **argv)
+{
+ IMAGE *in, *out;
+ IMAGE *trImage;
+
+ //if (im_init_world (argv[0]))
+ //error_exit ("unable to start VIPS");
+
+ if (argc != 4)
+ error_exit ("%s transform-image input-image output-image", argv[0]);
+
+ if (!(trImage = im_open (argv[1], "r")) ||
+ !(in = im_open (argv[2], "r")) ||
+ !(out = im_open (argv[3], "w")) ||
+ output_resample_image (trImage, in, out))
+ error_exit ("unable to run operation");
+
+ printf ("b4 closing images and also main\n");
+
+ im_close (in);
+ im_close (trImage);
+ im_close (out);
+
+ return 0;
+}
diff -r 000000000000 -r 7c5f0a3fa0fe src/vips/transform.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/vips/transform.c Tue Aug 26 05:44:10 2008 +0000
@@ -0,0 +1,134 @@
+#include "stdio.h"
+#include "stdlib.h"
+#include <string.h>
+#include <ctype.h>
+#include <stdarg.h>
+#include <assert.h>
+
+#include <parser/tparser.h>
+#include <vips/vips.h>
+#include "transform.h"
+
+#define DEBUG
+
+pt_transform *
+transform_new_from_file( char *transform , int *width, int *height, int imgNr )
+{
+ pt_script *script = NULL;
+ script = panoScriptParse(transform, TRUE);
+ if (script == NULL) {
+ printf("Parsing error\n");
+ return NULL;
+ } else {
+ /*panoScriptDump(script);*/
+ pt_transform * trn = panoTransformCreate(script,imgNr);
+
+ *width = script->pano.width;
+ *height = script->pano.height;
+
+#ifdef DEBUG
+ printf( "transform_new_from_file: \"%s\" (%p)\n", transform, trn);
+#endif
+
+ /*hope after this step pt_script is of no use, so we can dispose it*/
+ panoParserDispose(&script);
+ return( trn );
+ }
+}
+
+int
+transform_destroy( pt_transform *trn )
+{
+#ifdef DEBUG
+ printf( "transform_destroy: %p\n", trn );
+#endif
+
+ /*I think panoTransformDispose will take care of freeing the memory */
+ panoTransformDispose(&trn);
+
+ return( 0 );
+}
+
+static int transform_image_build_gen( REGION *or, void *dummy, pt_transform *trn )
+{
+ Rect *r;
+ int le, to, ri, bo, x, y;
+ double *q, xp, yp;
+
+ r = &or->valid;
+ le = r->left;
+ to = r->top;
+ ri = IM_RECT_RIGHT( r );
+ bo = IM_RECT_BOTTOM( r );
+
+ for( y = to; y < bo; y++ ) {
+ q = (double *) IM_REGION_ADDR( or, le, y );
+
+ for( x = le; x < ri; x++ ) {
+ /*transform_coordinates( trn, x, y, &xp, &yp );*/
+ panoTransformInverse(trn, x,y, &xp,&yp);
+ /*printf("%f, %f ", xs, ys);*/
+
+ q[0] = xp;
+ q[1] = yp;
+ /*printf("xp = %f, yp = %f\n", xp, yp);*/
+ q += 2;
+ }
+ }
+ return( 0 );
+}
+
+/* Make a two band image ... band 0 is x coordinates, band 1 is y
+ * coordinates.
+ */
+int transform_image_build( IMAGE *out,
+ pt_transform *trn, const int xsize, const int ysize )
+{
+ if( xsize <= 0 || ysize <= 0 ) {
+ im_error( "im_transform_image_build", _( "bad size" ) );
+ return( -1 );
+ }
+ if( im_poutcheck( out ) )
+ return( -1 );
+
+ im_initdesc( out, xsize, ysize, 2, IM_BBITS_DOUBLE, IM_BANDFMT_DOUBLE,
+ IM_CODING_NONE, IM_TYPE_MULTIBAND, 1.0, 1.0, 0, 0 );
+
+ if( im_demand_hint( out, IM_ANY, NULL ) )
+ return( -1 );
+
+ if( im_generate( out,
+ NULL, transform_image_build_gen, NULL, trn, NULL ) )
+ return( -1 );
+
+ return( 0 );
+}
+
+
+int transform_image(IMAGE *out, char *transformFile, int imgNr)
+{
+ int width, height;
+ pt_transform *trn;
+
+ /*printf("starting core function\n");
+ printf("filename: %s, image no. = %d\n", transformFile, imgNr);*/
+ /*width and height will be loaded from pt_script */
+ if( !(trn = transform_new_from_file( transformFile, &width, &height, imgNr )) ) {
+ im_error( "transform_image_build",
+ _( "unable to build transform" ) );
+ return( -1 );
+ } else {
+ printf("transform from new file successful\n");
+ }
+
+ if( im_add_close_callback( out,
+ (im_callback_fn) transform_destroy, trn, NULL ) ) {
+ transform_destroy( trn );
+ return( -1 );
+ }
+
+ if( transform_image_build( out, trn, width, height ) )
+ return( -1 );
+
+ return( 0 );
+}
diff -r 000000000000 -r 7c5f0a3fa0fe src/vips/transform.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/vips/transform.h Tue Aug 26 05:44:10 2008 +0000
@@ -0,0 +1,15 @@
+/* i18n placeholder.
+ */
+#include "panotools-wrappers/pttransform.h"
+#include <vips/vips.h>
+
+#define _(S) (S)
+
+/*Changed the signature to load width and height from pt_script, also the dummy transform structure
+is no longer needed, I use pt_transform everywhere instead*/
+int transform_image_build( IMAGE *out, pt_transform *trn, const int xsize, const int ysize );
+int transform_image(IMAGE *out, char *transformFile, int imgNr);
+pt_transform *transform_new_from_file( char *transform , int *width, int *height, int imgNr);
+int transform_destroy( pt_transform *trn );
+
+
diff -r 000000000000 -r 7c5f0a3fa0fe src/vips/transmap.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/vips/transmap.c Tue Aug 26 05:44:10 2008 +0000
@@ -0,0 +1,105 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdarg.h>
+#include <assert.h>
+
+#define DEBUG
+
+#include <vips/vips.h>
+#include <parser/tparser.h>
+#include "transform.h"
+#include "resample.h"
+#include "maskgen.h"
+
+int main(int argc, char *argv[])
+{
+
+ /*if (im_init_world (argv[0]))
+ error_exit ("unable to start VIPS");*/
+
+ if (argc != 2) {
+ printf("Usage: %s script-file-name\n", argv[0]);
+ exit(1);
+ }
+
+ pt_script *script = NULL;
+ script = panoScriptParse(argv[1], TRUE);
+ if (script == NULL) {
+ printf("Parsing error\n");
+ exit(1);
+ } else {
+
+ int imageCount = panoScriptGetInputImagesCount(script);
+ int i;
+ for(i = 0; i< imageCount; i++) {
+
+ char outputImage[100], outputImageMask[100];
+ IMAGE *out, *coordImage, *input;
+ IMAGE *outMask, *tmpMask[4];
+ int type = 2;
+ static const char *suffs[] = { ".tif", ".tiff", ".png", NULL };
+
+ sprintf(outputImage, "%s%d.tif", "out", i);
+ sprintf(outputImageMask, "%s%dMask.v", "out", i);
+
+ out = im_open (outputImage, "w");
+ coordImage = im_open_local(out, "coordImage", "p");
+ outMask = im_open_local(out, outputImageMask, "w");
+
+ if( transform_image( coordImage, argv[1], i) ) {
+ printf("transform image error\n");
+ exit(1);
+ }
+
+ printf("transformation done\n");
+ pt_script_image * inputImg = panoScriptGetInputImage(script, i);
+ if(im_open_local_array (out, tmpMask, 4, "mask", "p"))
+ return (-1);
+ if (!(input = im_open_local (out, inputImg->name, "r")))
+ error_exit ("unable to run operation\n");
+
+
+ /*a = isFormat(out, inputImg->name, "tif");
+ b = isFormat(out, inputImg->name, "png");
+ if(a == -1 || b == -1)
+ error_exit ("unable to run operation\n");*/
+
+ if(im_filename_suffix_match(inputImg->name, suffs ) && (input->Bands == 4)) {
+
+ if(im_extract_band(input, tmpMask[0], 3) ||
+ im_moreconst(tmpMask[0], tmpMask[1], 127.0))
+ return (-1);
+ } else {
+
+ if(im_black(tmpMask[0], input->Xsize, input->Ysize, 1) ||
+ (im_invert(tmpMask[0], tmpMask[1])))
+ return (-1);
+ }
+
+ printf("initial mask creation successful\n");
+ pt_transform * trans = panoTransformCreate(script,i);
+
+ if(trans->crop_circular == 1) {
+
+ if(makeCircularMask(tmpMask[2], input->Xsize, input->Ysize,
+ trans->crop_circular_cx, trans->crop_circular_cy,
+ trans->crop_circular_radius) ||
+ im_andimage(tmpMask[1], tmpMask[2], tmpMask[3]) ||
+ output_resample_image (coordImage, input, out, outMask, tmpMask[3], type))
+ return (-1);
+
+ } else if (output_resample_image (coordImage, input, out, outMask, tmpMask[1], type))
+ error_exit ("unable to run operation\n");
+
+ printf("resampling done\n");
+ printf("saving %s and %s....\n", outputImage, outputImageMask);
+ im_close(out);
+
+ }
+ }
+
+ return 0;
+}
+
|