ENH: Move the ClampImageFilter to the ImageIntensity module (#3016).

With the new feature allowing the ClampImageFilter to use
custom bounds, it makes more sense to have it in the
ImageIntensity module.

Change-Id: I411f36d19b64b2149b6cdcb6b0017397b848bd7b
COMP: Add preprocessor symbols to double-conversion for OS X PPC

The powerpc preprocessor definitions did not include the ones
actually found on Mac OS X on PPC. Added these flags to utils.h

Change-Id: Ifd5e83295c7e5372616c1fc5a51280658f9d6abe
COMP: Fix project linking against ITK that does not use VtkGlue.

The problem:

ITK is built with the ITKVtkGlue or ITKLevelSetsv4Visualization module enabled.
A project that uses ITK, but does not use VTK, does a

find_package(ITK REQUIRED)
include(${ITK_USE_FILE})

but if the VTK_DIR that was specified for ITKVtkGlue is at a build tree
location, CMake does not know where to find the VTK libraries.

The solution:

In the per-VTK-module export code, we should include VTKTargets.cmake so CMake
knows where to find the VTK libraries.  To do so, run find_package(VTK_DIR
NO_MODULE REQUIRED) with the VTK_DIR used during ITK configuration.

Change-Id: I6c74891f97da80c1b1ac352b8f7495439c80d610
BUG: initialize InverseCovariance size with degenerate matrix

This patch fixes a segfault with VectorConfidenceConnected when used
with VectorImages and only one initial seed. This was caused by an
inverse matrix not being initialized correctly for variable length
measurement vectors.

Change-Id: I81bd2c9afe35f726d552c08849dd3c80710bca05
BUG: Using CMake variable in external builds with autoconf environment

Previously, the external projects of FFTW, SWIG and PCRE were affected
by environmental variable such as CC, CXX, CFLAGS etc. The could be
tested by setting CXX=/dev/null in the environment. Additionally,
these setting could change from when cmake was first run to when the
external project was (re)configured and compiled.

Now, the environment variable which effect the autoconf are not set in
via the "env" command before configuration.

Change-Id: Ie2d4f43c10d40186062a2e2917eff26b03b9815c
BUG: Memory leak after failed RegisterFactory

If a RegisterFactory fails, the opened library was not closed. This
resulted in a memory leak.

This patch closes factories that fail to load.

Also, RegisterFactory now returns true if the factory loads and false
if it does not load.

Change-Id: If8cc37469b5d760d453b818d1c6a35058ab4d1ea
COMP: Address unused parameter warning in GPU code

Change-Id: Ie2489e7708a06fe4eb46577a2b3e91f137c32ca1
BUG: Only thread 0 should report progress in LabelMapFilters

The progress update observer is frequently used to update GUI
progress. The progress should only be updated by the main thread,
otherwise this common use will segfault with the gui update.

The LabelMapFilter was updated with a manual update to the filters
progress, additionally the abort status is also check.

Additionally, the mutex lock was change to use a holder to follow the
Resource Acquisition Is Initialization (RAII), principle. If an
exception occurs the locked block, the lock will automatically be
released.

Change-Id: I001066f59cc336bc8f54ef7299e2f8a030f32ce8
BUG: Only thread 0 should report progress.

The progress update observer is frequently used to update GUI
progress. The progress should only be updated by the main thread,
otherwise this common uses will segfault with the gui update.

The LabelMapFilter was updated with a manual update to the filters
progress, additionally the abort status is also check.

Change-Id: I1540ee5785a26b196524f51ac604d3bfcd18d0b0
COMP: Adding missing header

WrapITK builds are getting a compilation error from
ProgressReporter not being defined.

Change-Id: I191a02acef380b560c4cd3cc752ec815a9a5f998
BUG: Avoid using def file when BUILD_SHARED_LIBS is off

Using the def file causes build errors like this with the Visual
Studio 11 linker when building static libraries:

  [2445/5676] Linking C static library lib\itktiff-4.4.lib
  FAILED: cmd.exe /c cd . && C:\PROGRA~2\MICROS~1.0\VC\bin\link.exe /lib /nologo /DEF:"C:\dev\...
  itktiff.def : error LNK2001: unresolved external symbol TIFFCheckTile

Since the def file is only for specifying exports in the shared
library build, it should be ok to leave it out for static library
builds.

Change-Id: Ic67f8b763b16b469a60064a6262653f2e6df13df
BUG: Do not undefine _WIN32_WINNT

Instead, check to see if the includer has already defined it,
and if so, leave the value alone.

Only if the includer did not define it beforehand should a value
be defined here.

With an undef in there, it may mess up files included afterwards
which expect the value set by the including project, not a different
(and forced!) value from an ITK header.

Change-Id: I3ae8e44c8d0573f6fc4f0f012941a3d309f51941
BUG: CSVFileReader was reading all values as NaN

The ConvertStringToValueType method of CSVFileReaderBase.h was
previously not working correctly.  The operations on the istringstream
resulted in all calls returning NaN even if valid values were passed
in.  This means that every value read from a CSV file was converted to
NaN!  This was not caught by the itkCSVArray2DFileReaderWriterTest
because it was comparing the file that was read to the expected value
without considering NaN values.  This patch corrects the error in
CSVFileReaderBase.h. It also corrects the test so that it will catch
such errors.  In other words, running this updated test on the old
CSVFileReaderBase.h will result in a failed test.

Change-Id: Ic5643ff67cc5fdfb2c7b408e760c0fe471be9be1
COMP: Type mis-match for comparison operator

In the specialized operator= the types will not
match, so the test for being the same pointer
is not valid.

itkDiffusionTensor3D.h:124:13: error: comparison of distinct pointer types
   ('itk::DiffusionTensor3D<double> *' and 'const DiffusionTensor3D<float> *')
   (this != &pa)
    ~~~~ ^  ~~~

Change-Id: I6fabab1d546226880cbc5648a698b60b2e71fe9e
BUG: Fix InverseDisplacementFieldImageFilter bug

Further description can be found in jira issue (#3009).

A displacement field represent the displacement required to move from image1 to image2 :

image2_position = f(image1_position) + image1_position

Inverting such a field consist in estimating f^-1 such that
image1_position = f^-1(image2_position) + image2_position

at each location of image2 grid, while we in fact know f^-1 only at f(image1_position) + image1_position, which are most likely off image2 grid.

To do so, the InverseDisplacementFieldImageFilter makes use of Splines function, which will interpolate the displacement at image2 grid positions.

The spline transform is given source and target points from the function to estimate, which is f^-1. for each grid position in image1 :

    source point should be f(image1_position) + image1_position
    target point should be image1-image2 = -f(image1)

But in the filter code before this patch, we can read that source point given to the spline is only image1_position, not f(image1_position) + image1_position.

As a result, the inverse function estimated by the spline transform is wrong.

As asked in the review, the filter test has been modified to show the improper behaviour before the patch and the correct behaviour after the patch. Please note that the previous version of the test did not test for output validity, but only for correct execution (no regression testing on algorithm output).

As asked by the last review, I slightly rewrote the filter code to enhance readibility by avoiding confusion between landmarks and displacements.

Change-Id: Iddfb0a4332f12212feaec8a3e54f48c7ce41e272
Merge topic 'DoubleConversionPPCFix'

5e6b8cd COMP: Add preprocessor symbols to double-conversion for OS X PPC
BUG: Inconsistency detected by ld.so due to static const string

Change-Id: I77f98557c0e905247fedde14243c25fc9d731b8f
BUG: Inconsistency detected by ld.so due to static const string

Change-Id: I56202d38db4deff8b63f58b7606127050842ca55
BUG: Fix FFTW install paths in ITKConfig.cmake (ITK-2995).

Change-Id: Ibf284cc918f3975de3ee8222dddb71a876aa6566
COMP: Fix TIFF on big endian systems

This is similar to the fix I submitted April 24, 2012 (367953).
Basically on big endian systems you need to check if
WORDS_BIGENDIAN is defined, not its value.

This fix was overwritten when libtiff 4.0.3 was pulled in. Also,
libtiff 4.0.3 contained a second instance of this error.

The original full description is here:
     http://lists.debian.org/debian-med/2012/04/msg00070.html