SCI Seg3D Mailing List

Text archives Help


[Seg3D] Re: Re: Re: Fix for 2.1.4 segfault in Ubuntu Precise


Chronological Thread 
  • From: Robert Blake <rob.c.blake.3@gmail.com>
  • To: seg3d@sci.utah.edu
  • Subject: [Seg3D] Re: Re: Re: Fix for 2.1.4 segfault in Ubuntu Precise
  • Date: Thu, 06 Feb 2014 16:49:40 -0500

I've attached another patch that gives users the option of using system
libraries or the pre-packaged libraries when compiling seg3d 2.1.4.  I'm
also working on a patch for 2.1.5. 

I've confirmed that this patch also fixes the bug on Ubuntu precise. 
AFAICT, this patch is all that's needed to package the program for
debian and fedora.

Re: controlling library versions, I totally understand your point of
view, and I do the same thing for my personal projects.  In this case
however, the bug originated /from/ Seg3D's "External" libraries. Said
bug had since been fixed in Ubuntu/Debian repositories, but Seg3D was
unable to take advantage of that bugfix.  My attached patch doesn't
remove the Externals directory, but instead gives users the option of
using better-tested versions of the standard libraries if they are
available.

Both Debian and Fedora give you the option of mandating very specific
library versions for your project.  If I were to build a Seg3D debian
package, could you let me know what library versions I should mandate?


On 02/06/2014 04:22 PM, Ayla Khan wrote:
> Hi Rob,
>
> Thank you very much for reporting this bug and sending the patch. I'll look 
> into a more streamlined way to incorporate this fix into Seg3D 2.1.5.
>
> In general, it is preferable from our point of view to build against 
> library versions that we control since we have to support a broad range of 
> platforms (Windows, Mac OS X and different Linux distributions). Including 
> specific versions of third-party libraries allows us to maintain stable 
> Seg3D builds across multiple platforms with the least amount of effort and 
> cost.
>
> Ayla
>
> On Feb 4, 2014, at 11:11 PM, Robert Blake wrote:
>
>> A quick followup:
>>
>> A permanent fix would involve giving users the option of using the
>> system's libfreetype instead of Seg3D's libfreetype on Linux. 
>>
>> Would you be interested if I wrote a patch so that Linux users could use
>> their package-installed libraries instead of Seg3D's Externals
>> directory? This might make package maintainers happy-- I'd love to see
>> Seg3D included in the debian and fedora repositories.  See
>>
>https://lists.debian.org/debian-med/2013/05/msg00052.html
>>
>> for the relevant discussion last year on the debian lists.
>>
>> On 02/05/2014 01:08 AM, Robert Blake wrote:
>>> Hi everyone,
>>>
>>> I'm a big fan of Seg3D, but over the last year+ I've noticed some
>>> instability in the Linux version on Ubuntu precise, 12.04.  Seg3D tends
>>> to crash intermittently when opening up any file dialog.
>>>
>>> Someone has already filed a bug report for this bug-- this is the same
>>> behavior that I am seeing:
>>> https://gforge.sci.utah.edu/gf/project/seg3d2/tracker/?action=TrackerItemEdit&tracker_id=710&tracker_item_id=772
>>>
>>>
>>> jeoren checked in the following fix for this:
>>> https://gforge.sci.utah.edu/svn/seg3d2/trunk@1708
>>>
>>> However, this fix doesn't actually solve the problem.
>>>
>>> As far as I can tell, the the problem occurs when Seg3D tries to load a
>>> native file dialog on Ubuntu.  This causes a gtk-2 file dialog to
>>> appear, which in turn uses libfreetype to render the dialog.  Ubuntu's
>>> gtk-2 libraries expect to use the updated Ubuntu libfreetype libraries,
>>> but instead they access Seg3D's internal statically linked libfreetype
>>> library instead.  This causes intermittent invalid memory accesses.
>>>
>>> I've attached a patch for 2.1.4 that DOES seem to solve the problem once
>>> and for Linux, although it is an ugly kludge.  I replaced all of the
>>> native file dialogs with Qt file dialogs.  I've been using this version
>>> heavily for 1 week and it hasn't segfaulted once.
>>>
>>> Sending this patch here in case someone else has the same problem.
>>> Rob
>>>

diff --git a/src/Application/Filters/Actions/ActionResample.cc b/src/Application/Filters/Actions/ActionResample.cc
index 07eb8e9..c76fac7 100644
--- a/src/Application/Filters/Actions/ActionResample.cc
+++ b/src/Application/Filters/Actions/ActionResample.cc
@@ -28,7 +28,7 @@
 
 // teem includes
 #include <teem/nrrd.h>
-#include <teem/privateNrrd.h>
+//#include <teem/privateNrrd.h> // when using system NRRD, this header doesn't exist.
 
 // Core includes
 #include <Core/DataBlock/NrrdDataBlock.h>
@@ -243,22 +243,42 @@ ResampleAlgo::~ResampleAlgo()
 	}
 }
 
+static inline int _nrrdKindAltered(int kindIn, int resampling) {
+  int kindOut;
+
+  if (nrrdStateKindNoop) {
+    kindOut = nrrdKindUnknown;
+    /* HEY: setting the kindOut to unknown is arguably not a no-op.
+       It is more like pointedly and stubbornly simplistic. So maybe
+       nrrdStateKindNoop could be renamed .. */
+  } else {
+    if (nrrdKindIsDomain(kindIn)
+        || (0 == nrrdKindSize(kindIn) && !resampling)) {
+      kindOut = kindIn;
+    } else {
+      kindOut = nrrdKindUnknown;
+    }
+  }
+  return kindOut;
+}
+
+
 // NOTE: This function is copied from the _nrrdResampleOutputUpdate function
 static void UpdateNrrdAxisInfo( Nrrd* nout, NrrdResampleContext* rsmc )
 {
     nrrdSpaceVecCopy( nout->spaceOrigin, rsmc->nin->spaceOrigin );
+    nrrdAxisInfoCopy( nout, rsmc->nin, NULL, 
+                     ( NRRD_AXIS_INFO_SIZE_BIT
+                      | NRRD_AXIS_INFO_SPACING_BIT
+                      | NRRD_AXIS_INFO_THICKNESS_BIT
+                      | NRRD_AXIS_INFO_MIN_BIT
+                      | NRRD_AXIS_INFO_MAX_BIT
+                      | NRRD_AXIS_INFO_SPACEDIRECTION_BIT
+                      | NRRD_AXIS_INFO_CENTER_BIT
+                      | NRRD_AXIS_INFO_KIND_BIT ) );
     for ( unsigned int axIdx = 0; axIdx < rsmc->dim; axIdx++ ) 
 	{
         double minIdxFull, maxIdxFull, zeroPos;
-        _nrrdAxisInfoCopy( nout->axis + axIdx, rsmc->nin->axis + axIdx,
-                          ( NRRD_AXIS_INFO_SIZE_BIT
-                           | NRRD_AXIS_INFO_SPACING_BIT
-                           | NRRD_AXIS_INFO_THICKNESS_BIT
-                           | NRRD_AXIS_INFO_MIN_BIT
-                           | NRRD_AXIS_INFO_MAX_BIT
-                           | NRRD_AXIS_INFO_SPACEDIRECTION_BIT
-                           | NRRD_AXIS_INFO_CENTER_BIT
-                           | NRRD_AXIS_INFO_KIND_BIT ) );
         /* now set all the per-axis fields we just abstained from copying */
         /* size was already set */
         nout->axis[ axIdx ].spacing = ( rsmc->nin->axis[ axIdx ].spacing
@@ -267,9 +287,13 @@ static void UpdateNrrdAxisInfo( Nrrd* nout, NrrdResampleContext* rsmc )
         nout->axis[ axIdx ].thickness = AIR_NAN;
         /* We had to assume a specific centering when doing resampling */
         nout->axis[ axIdx ].center = rsmc->axis[ axIdx ].center;
-        _nrrdResampleMinMaxFull( &minIdxFull, &maxIdxFull,
-                                rsmc->axis[ axIdx ].center,
-                                rsmc->nin->axis[ axIdx ].size );
+        if (nrrdCenterCell == rsmc->axis[ axIdx ].center) {
+           minIdxFull = -0.5;
+           maxIdxFull = rsmc->nin->axis[ axIdx ].size - 0.5;
+        } else {
+           minIdxFull = 0.0;
+           maxIdxFull = rsmc->nin->axis[ axIdx ].size - 1.0;
+        }
         nout->axis[ axIdx ].min = AIR_AFFINE( minIdxFull,
                                            rsmc->axis[axIdx].min,
                                            maxIdxFull,
diff --git a/src/Application/LayerIO/GDCMLayerImporter.cc b/src/Application/LayerIO/GDCMLayerImporter.cc
index ce144d8..20757db 100644
--- a/src/Application/LayerIO/GDCMLayerImporter.cc
+++ b/src/Application/LayerIO/GDCMLayerImporter.cc
@@ -268,7 +268,8 @@ bool GDCMLayerImporterPrivate::read_header()
 		{
 			gdcm::Attribute< 0x0018, 0x0050 > slice_thickness;
 			slice_thickness.SetFromDataElement( de );
-			double thickness = slice_thickness.GetValue( 0 );
+			double thickness = 0;
+			thickness = slice_thickness.GetValue();
 			if ( thickness > epsilon )
 			{
 				this->z_spacing_ = thickness;
@@ -287,7 +288,8 @@ bool GDCMLayerImporterPrivate::read_header()
 		{
 			gdcm::Attribute< 0x0018, 0x0088 > slice_thickness;
 			slice_thickness.SetFromDataElement( de );
-			double thickness = slice_thickness.GetValue( 0 );
+			double thickness = 0;
+			thickness = slice_thickness.GetValue();
 			if ( thickness > epsilon )
 			{
 				this->z_spacing_ = thickness;
diff --git a/src/Application/Tool/ToolInfo.cc b/src/Application/Tool/ToolInfo.cc
index 53c13ae..6e8ad95 100644
--- a/src/Application/Tool/ToolInfo.cc
+++ b/src/Application/Tool/ToolInfo.cc
@@ -27,7 +27,7 @@
  */
 
 // TinyXML includes
-#include <Externals/tinyxml/tinyxml.h>
+#include <tinyxml.h>
 
 // Core includes
 #include <Core/Utils/Exception.h>
diff --git a/src/CMake/Modules/FindGLEW.cmake b/src/CMake/Modules/FindGLEW.cmake
new file mode 100644
index 0000000..2d76562
--- /dev/null
+++ b/src/CMake/Modules/FindGLEW.cmake
@@ -0,0 +1,30 @@
+# - Find the OpenGL Extension Wrangler Library (GLEW)
+# This module defines the following variables:
+#  GLEW_INCLUDE_DIRS - include directories for GLEW
+#  GLEW_LIBRARIES - libraries to link against GLEW
+#  GLEW_FOUND - true if GLEW has been found and can be used
+
+#=============================================================================
+# Copyright 2012 Benjamin Eikel
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+# (To distribute this file outside of CMake, substitute the full
+#  License text for the above reference.)
+
+find_path(GLEW_INCLUDE_DIR GL/glew.h)
+find_library(GLEW_LIBRARY NAMES GLEW glew32 glew glew32s PATH_SUFFIXES lib64)
+
+set(GLEW_INCLUDE_DIRS ${GLEW_INCLUDE_DIR})
+set(GLEW_LIBRARIES ${GLEW_LIBRARY})
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(GLEW
+                                  REQUIRED_VARS GLEW_INCLUDE_DIR GLEW_LIBRARY)
+
+mark_as_advanced(GLEW_INCLUDE_DIR GLEW_LIBRARY)
diff --git a/src/CMake/Modules/FindSqlite.cmake b/src/CMake/Modules/FindSqlite.cmake
new file mode 100644
index 0000000..cfdd566
--- /dev/null
+++ b/src/CMake/Modules/FindSqlite.cmake
@@ -0,0 +1,48 @@
+# - Try to find the sqlite library
+# Once done this will define
+#
+#  SQLITE_FOUND - system has sqlite
+#  SQLITE_INCLUDE_DIRS - the sqlite include directory
+#  SQLITE_LIBRARIES - Link these to use sqlite
+#
+# Define SQLITE_MIN_VERSION for which version desired.
+#
+
+INCLUDE(FindPkgConfig)
+
+IF(Sqlite_FIND_REQUIRED)
+	SET(_pkgconfig_REQUIRED "REQUIRED")
+ELSE(Sqlite_FIND_REQUIRED)
+	SET(_pkgconfig_REQUIRED "")
+ENDIF(Sqlite_FIND_REQUIRED)
+
+IF(SQLITE_MIN_VERSION)
+	PKG_SEARCH_MODULE(SQLITE ${_pkgconfig_REQUIRED} sqlite>=${SQLITE_MIN_VERSION} sqlite${SQLITE_MIN_VERSION})
+ELSE(SQLITE_MIN_VERSION)
+	PKG_SEARCH_MODULE(SQLITE ${_pkgconfig_REQUIRED} sqlite)
+ENDIF(SQLITE_MIN_VERSION)
+
+IF(NOT SQLITE_FOUND AND NOT PKG_CONFIG_FOUND)
+	FIND_PATH(SQLITE_INCLUDE_DIRS sqlite${SQLITE_MIN_VERSION}.h)
+	FIND_LIBRARY(SQLITE_LIBRARIES sqlite${SQLITE_MIN_VERSION})
+
+	# Report results
+	IF(SQLITE_LIBRARIES AND SQLITE_INCLUDE_DIRS)
+		SET(SQLITE_FOUND 1)
+		IF(NOT Sqlite_FIND_QUIETLY)
+			MESSAGE(STATUS "Found Sqlite: ${SQLITE_LIBRARIES}")
+		ENDIF(NOT Sqlite_FIND_QUIETLY)
+	ELSE(SQLITE_LIBRARIES AND SQLITE_INCLUDE_DIRS)	
+		IF(Sqlite_FIND_REQUIRED)
+			MESSAGE(SEND_ERROR "Could not find Sqlite")
+		ELSE(Sqlite_FIND_REQUIRED)
+			IF(NOT Sqlite_FIND_QUIETLY)
+				MESSAGE(STATUS "Could not find Sqlite")	
+			ENDIF(NOT Sqlite_FIND_QUIETLY)
+		ENDIF(Sqlite_FIND_REQUIRED)
+	ENDIF(SQLITE_LIBRARIES AND SQLITE_INCLUDE_DIRS)
+ENDIF(NOT SQLITE_FOUND AND NOT PKG_CONFIG_FOUND)
+
+# Hide advanced variables from CMake GUIs
+MARK_AS_ADVANCED(SQLITE_LIBRARIES SQLITE_INCLUDE_DIRS)
+
diff --git a/src/CMake/Modules/FindTeem.cmake b/src/CMake/Modules/FindTeem.cmake
new file mode 100644
index 0000000..ce4693f
--- /dev/null
+++ b/src/CMake/Modules/FindTeem.cmake
@@ -0,0 +1,108 @@
+# Copied from https://github.com/lbaehren/CMakeModules on 2013-08-06
+#--------------------------------------------------------------------------------
+# Copyright (c) 2012-2013, Lars Baehren <lbaehren@gmail.com>
+# 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.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER OR 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.
+#--------------------------------------------------------------------------------
+
+# - Check for the presence of TEEM
+#
+# The following variables are set when TEEM is found:
+#  TEEM_FOUND      = Set to true, if all components of TEEM have been found.
+#  TEEM_INCLUDES   = Include path for the header files of TEEM
+#  TEEM_LIBRARIES  = Link these to use TEEM
+#  TEEM_LFLAGS     = Linker flags (optional)
+
+if (NOT TEEM_FOUND)
+
+  if (NOT TEEM_ROOT_DIR)
+    set (TEEM_ROOT_DIR ${CMAKE_INSTALL_PREFIX})
+  endif (NOT TEEM_ROOT_DIR)
+
+  ##_____________________________________________________________________________
+  ## Check for the header files
+
+  find_path (TEEM_INCLUDES
+    NAMES tenMacros.h nrrdDefines.h
+    HINTS ${TEEM_ROOT_DIR} ${CMAKE_INSTALL_PREFIX}
+    PATH_SUFFIXES include include/teem
+    )
+
+  ##_____________________________________________________________________________
+  ## Check for the library
+
+  find_library (TEEM_LIBRARIES teem
+    HINTS ${TEEM_ROOT_DIR} ${CMAKE_INSTALL_PREFIX}
+    PATH_SUFFIXES lib
+    )
+
+  ##_____________________________________________________________________________
+  ## Check for the executable
+
+  foreach (_teemProgram
+      nrrdSanity
+      overrgb
+      ilk
+      mrender
+      miter
+      vprobe
+      gprobe
+      unu
+      tend
+      )
+    ## Convert name to upper case
+    string(TOUPPER ${_teemProgram} _var)
+    ## Find executable
+    find_program (TEEM_${_var}_EXECUTABLE ${_teemProgram}
+      HINTS ${TEEM_ROOT_DIR} ${CMAKE_INSTALL_PREFIX}
+      PATH_SUFFIXES bin
+      )
+  endforeach (_teemProgram)
+
+  ##_____________________________________________________________________________
+  ## Actions taken when all components have been found
+
+  find_package_handle_standard_args (TEEM DEFAULT_MSG TEEM_LIBRARIES TEEM_INCLUDES)
+
+  if (TEEM_FOUND)
+    if (NOT TEEM_FIND_QUIETLY)
+      message (STATUS "Found components for TEEM")
+      message (STATUS "TEEM_ROOT_DIR  = ${TEEM_ROOT_DIR}")
+      message (STATUS "TEEM_INCLUDES  = ${TEEM_INCLUDES}")
+      message (STATUS "TEEM_LIBRARIES = ${TEEM_LIBRARIES}")
+    endif (NOT TEEM_FIND_QUIETLY)
+  else (TEEM_FOUND)
+    if (TEEM_FIND_REQUIRED)
+      message (FATAL_ERROR "Could not find TEEM!")
+    endif (TEEM_FIND_REQUIRED)
+  endif (TEEM_FOUND)
+
+  ##_____________________________________________________________________________
+  ## Mark advanced variables
+
+  mark_as_advanced (
+    TEEM_ROOT_DIR
+    TEEM_INCLUDES
+    TEEM_LIBRARIES
+    )
+
+endif (NOT TEEM_FOUND)
diff --git a/src/CMake/Modules/FindTinyXML.cmake b/src/CMake/Modules/FindTinyXML.cmake
new file mode 100644
index 0000000..29547d4
--- /dev/null
+++ b/src/CMake/Modules/FindTinyXML.cmake
@@ -0,0 +1,72 @@
+# - Find TinyXML
+# Find the native TinyXML includes and library
+#
+#   TINYXML_FOUND        - True if TinyXML found.
+#   TINYXML_INCLUDE_DIRS - where to find tinyxml.h, etc.
+#   TINYXML_LIBRARIES    - List of libraries when using TinyXML.
+#
+#   TINYXML_VERSION       - Full version of TinyXML.
+#   TINYXML_VERSION_MAJOR - Major version of TinyXML.
+#   TINYXML_VERSION_MINOR - Minor version of TinyXML.
+#   TINYXML_VERSION_PATCH - Patch version of TinyXML.
+#
+
+LIST( APPEND TINYXML_NAMES "tinyxml" )
+
+FIND_PATH(
+  TINYXML_INCLUDE_DIR
+  "tinyxml.h"
+  )
+FIND_LIBRARY(
+  TINYXML_LIBRARY
+  NAMES ${TINYXML_NAMES}
+  )
+MARK_AS_ADVANCED(
+  TINYXML_INCLUDE_DIR
+  TINYXML_LIBRARY
+  )
+
+IF( TINYXML_INCLUDE_DIR AND EXISTS "${TINYXML_INCLUDE_DIR}/tinyxml.h" )
+  FILE(
+    STRINGS "${TINYXML_INCLUDE_DIR}/tinyxml.h"
+    TINYXML_VERSION_MAJOR
+    REGEX "^const int TIXML_MAJOR_VERSION = [0-9]+;$"
+    )
+  FILE(
+    STRINGS "${TINYXML_INCLUDE_DIR}/tinyxml.h"
+    TINYXML_VERSION_MINOR
+    REGEX "^const int TIXML_MINOR_VERSION = [0-9]+;$"
+    )
+  FILE(
+    STRINGS "${TINYXML_INCLUDE_DIR}/tinyxml.h"
+    TINYXML_VERSION_PATCH
+    REGEX "^const int TIXML_PATCH_VERSION = [0-9]+;$"
+    )
+
+  STRING(
+    REGEX REPLACE "^.*TIXML_MAJOR_VERSION = ([0-9]+).*$" "\\1"
+    TINYXML_VERSION_MAJOR "${TINYXML_VERSION_MAJOR}"
+    )
+  STRING(
+    REGEX REPLACE "^.*TIXML_MINOR_VERSION = ([0-9]+).*$" "\\1"
+    TINYXML_VERSION_MINOR "${TINYXML_VERSION_MINOR}"
+    )
+  STRING(
+    REGEX REPLACE "^.*TIXML_PATCH_VERSION = ([0-9]+).*$" "\\1"
+    TINYXML_VERSION_PATCH "${TINYXML_VERSION_PATCH}"
+    )
+
+  SET( TINYXML_VERSION "${TINYXML_VERSION_MAJOR}.${TINYXML_VERSION_MINOR}.${TINYXML_VERSION_PATCH}" )
+ENDIF()
+
+SET( TINYXML_INCLUDE_DIRS "${TINYXML_INCLUDE_DIR}" )
+SET( TINYXML_LIBRARIES "${TINYXML_LIBRARY}" )
+
+# handle the QUIETLY and REQUIRED arguments and set TINYXML_FOUND to TRUE if
+# all listed variables are TRUE
+INCLUDE( "FindPackageHandleStandardArgs" )
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(
+  "TinyXML"
+  REQUIRED_VARS TINYXML_LIBRARIES TINYXML_INCLUDE_DIRS
+  VERSION_VAR TINYXML_VERSION
+  )
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index f2695f6..5657fd2 100755
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -129,24 +129,6 @@ ELSE (CMAKE_SIZEOF_VOID_P MATCHES 8)
 ENDIF (CMAKE_SIZEOF_VOID_P MATCHES 8)
 
 ###########################################
-# SETUP DEFINTIONS FOR EXTERNAL PACKAGES
-# To force a static build these flags
-# need to be set project wide.
-###########################################
-
-ADD_DEFINITIONS(-DGLEW_STATIC)
-ADD_DEFINITIONS(-DTEEM_STATIC)
-ADD_DEFINITIONS(-DLIBXML_STATIC)
-ADD_DEFINITIONS(-DTINYXML_STATIC)
-ADD_DEFINITIONS(-DBOOST_ALL_NO_LIB)
-ADD_DEFINITIONS(-DQT_NO_KEYWORDS)
-ADD_DEFINITIONS(-DTIXML_USE_STL)
-  
-SET(ITK_BUILD_SHARED_LIBS "STATIC")
-SET(ITK_USE_REVIEW TRUE CACHE BOOLEAN "Seg3D requires the ITK Review directory for proper filter operations." FORCE)
-SET(ITK_USE_REVIEW_STATISTICS TRUE CACHE BOOLEAN "Seg3D requires the ITK Review directory for proper filter operations." FORCE)
-
-###########################################
 # Flags for Microsoft Compiler
 ###########################################
 
@@ -197,21 +179,18 @@ INCLUDE(FindQt4)
 IF (QT_FOUND)
   SET(QT_USE_QTOPENGL 1)
   INCLUDE(${QT_USE_FILE})
+  INCLUDE_DIRECTORIES(${QT_INCLUDE_DIR})
 ELSE (QT_FOUND)
   MESSAGE(FATAL_ERROR "QT ${QT_MIN_VERSION} or later is required for building Seg3D")
 ENDIF (QT_FOUND)
 
 ENDIF(SEG3D_BUILD_INTERFACE)
 
+ADD_DEFINITIONS(-DQT_NO_KEYWORDS)
+
 ###########################################
-# Configure python
-OPTION(BUILD_WITH_PYTHON "Build with python support." ON)
-IF(BUILD_WITH_PYTHON)
-  ADD_DEFINITIONS(-DBUILD_WITH_PYTHON 
-				  -DPy_NO_ENABLE_SHARED 
-				  -DBOOST_PYTHON_STATIC_MODULE
-				  -DBOOST_PYTHON_STATIC_LIB)
-ENDIF(BUILD_WITH_PYTHON)
+
+LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake/Modules")
 
 ###########################################
 # External packages other than Qt
@@ -223,8 +202,227 @@ ENDIF(BUILD_WITH_PYTHON)
 # be build against different licensed 
 # versions of Qt.
 ###########################################
+OPTION(USE_SYSTEM_LIBRARIES "Use system libraries instead of Externals directory.  Use when packaging for Linux." OFF)
+
+MESSAGE(STATUS "Configuring External Packages")
+
+##################################################
+# ADDING ZLIB
+##################################################
+
+MESSAGE(STATUS "Configuring zlib")
+IF(USE_SYSTEM_LIBRARIES)
+  FIND_PACKAGE(ZLIB)
+  INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIRS})
+  SET(SCI_ZLIB_LIBRARY ${ZLIB_LIBRARIES})
+ELSE(USE_SYSTEM_LIBRARIES)
+  ADD_SUBDIRECTORY(Externals/zlib)
+  INCLUDE_DIRECTORIES(${SCI_ZLIB_INCLUDE})
+ENDIF(USE_SYSTEM_LIBRARIES)
+
+##################################################
+# ADDING MATLABIO
+##################################################
+
+MESSAGE(STATUS "Configuring MatlabIO")
+ADD_SUBDIRECTORY(Externals/MatlabIO)
+INCLUDE_DIRECTORIES(${SCI_MATLABIO_INCLUDE})
+
+##################################################
+# ADDING LIBPNG
+##################################################
+
+MESSAGE(STATUS "Configuring libpng")
+IF(USE_SYSTEM_LIBRARIES)
+  FIND_PACKAGE(PNG)
+  INCLUDE_DIRECTORIES(${PNG_INCLUDE_DIRS})
+  SET(SCI_PNG_LIBRARY ${PNG_LIBRARIES})
+ELSE(USE_SYSTEM_LIBRARIES)
+  ADD_SUBDIRECTORY(Externals/libpng)
+  INCLUDE_DIRECTORIES(${SCI_LIBPNG_INCLUDE})
+ENDIF(USE_SYSTEM_LIBRARIES)
+
+##################################################
+# ADDING TEEM
+##################################################
+
+# Teem depends on libpng and zlib, so make sure 
+# that these projects are included before Teem.
+
+MESSAGE(STATUS "Configuring teem")
+IF(USE_SYSTEM_LIBRARIES)
+  FIND_PACKAGE(Teem)
+  INCLUDE_DIRECTORIES(${TEEM_INCLUDES})
+  SET(SCI_TEEM_LIBRARY ${TEEM_LIBRARIES})
+ELSE(USE_SYSTEM_LIBRARIES)
+  ADD_DEFINITIONS(-DTEEM_STATIC)
+  ADD_SUBDIRECTORY(Externals/teem)
+  INCLUDE_DIRECTORIES(${SCI_TEEM_INCLUDE})
+ENDIF(USE_SYSTEM_LIBRARIES)
+
+##################################################
+# ADDING GLEW
+##################################################
+
+MESSAGE(STATUS "Configuring glew")
+IF(USE_SYSTEM_LIBRARIES)
+  FIND_PACKAGE(OpenGL)
+  FIND_PACKAGE(GLEW)
+  INCLUDE_DIRECTORIES(${GLEW_INCLUDE_DIRS})
+  SET(SCI_GLEW_LIBRARY ${GLEW_LIBRARIES} ${OPENGL_LIBRARIES})
+ELSE(USE_SYSTEM_LIBRARIES)
+  ADD_DEFINITIONS(-DGLEW_STATIC)
+  ADD_SUBDIRECTORY(Externals/glew)
+  INCLUDE_DIRECTORIES(${SCI_GLEW_INCLUDE})
+ENDIF(USE_SYSTEM_LIBRARIES)
+
+##################################################
+# ADDING FREETYPE
+##################################################
+
+MESSAGE(STATUS "Configuring freetype")
+IF(USE_SYSTEM_LIBRARIES)
+  FIND_PACKAGE(Freetype)
+  INCLUDE_DIRECTORIES(${FREETYPE_INCLUDE_DIRS})
+  SET(SCI_FREETYPE_LIBRARY ${FREETYPE_LIBRARIES})
+ELSE(USE_SYSTEM_LIBRARIES)
+  ADD_SUBDIRECTORY(Externals/freetype)
+  INCLUDE_DIRECTORIES(${SCI_FREETYPE_INCLUDE})
+ENDIF(USE_SYSTEM_LIBRARIES)
+
+##################################################
+# ADDING TINYXML
+##################################################
+
+MESSAGE(STATUS "Configuring tinyxml")
+IF(USE_SYSTEM_LIBRARIES)
+  FIND_PACKAGE(TinyXML)
+  INCLUDE_DIRECTORIES(${TINYXML_INCLUDE_DIRS})
+  SET(SCI_TINYXML_LIBRARY ${TINYXML_LIBRARIES})
+ELSE(USE_SYSTEM_LIBRARIES)
+  ADD_DEFINITIONS(-DLIBXML_STATIC)
+  ADD_DEFINITIONS(-DTINYXML_STATIC)
+  ADD_DEFINITIONS(-DTIXML_USE_STL)
+  ADD_SUBDIRECTORY(Externals/tinyxml)
+  INCLUDE_DIRECTORIES(${SCI_TINYXML_INCLUDE})
+ENDIF(USE_SYSTEM_LIBRARIES)
+
+##################################################
+# ADDING SQLITE
+##################################################
+
+MESSAGE(STATUS "Configuring SQLite")
+IF(USE_SYSTEM_LIBRARIES)
+  SET(SQLITE_MIN_VERSION 3)
+  FIND_PACKAGE(Sqlite)
+  INCLUDE_DIRECTORIES(${SQLITE_INCLUDE_DIRS})
+  SET(SCI_SQLITE_LIBRARY ${SQLITE_LIBRARIES})
+ELSE(USE_SYSTEM_LIBRARIES)
+  ADD_SUBDIRECTORY(Externals/sqlite)
+  INCLUDE_DIRECTORIES(${SCI_SQLITE_INCLUDE})
+ENDIF(USE_SYSTEM_LIBRARIES)
+
+##################################################
+# ADDING GDCM
+##################################################
+
+MESSAGE(STATUS "Configuring GDCM")
+IF(USE_SYSTEM_LIBRARIES)
+  FIND_PACKAGE(GDCM)
+  INCLUDE(${GDCM_USE_FILE})
+  INCLUDE_DIRECTORIES(${GDCM_INCLUDE_DIRS})
+  SET(SCI_GDCM_LIBRARY ${GDCM_LIBRARIES})
+ELSE(USE_SYSTEM_LIBRARIES)
+  ADD_SUBDIRECTORY(Externals/gdcm)
+  INCLUDE_DIRECTORIES(${SCI_GDCM_INCLUDE})
+ENDIF(USE_SYSTEM_LIBRARIES)
+
+
+##################################################
+# ADDING ITK
+##################################################
+
+MESSAGE(STATUS "Configuring insight toolkit")
+
+IF(USE_SYSTEM_LIBRARIES)
+  FIND_PACKAGE(ITK)
+  INCLUDE(${ITK_USE_FILE})
+  INCLUDE_DIRECTORIES(${ITK_INCLUDE_DIRS})
+  SET(SCI_ITK_LIBRARY ${ITK_LIBRARIES})
+ELSE(USE_SYSTEM_LIBRARIES)
+  # Force ITK not to install any libraries, header
+  # files etc. Because we don't need that stuff
+
+  SET(ITK_BUILD_SHARED_LIBS "STATIC")
+  SET(ITK_USE_REVIEW TRUE CACHE BOOLEAN "Seg3D requires the ITK Review directory for proper filter operations." FORCE)
+  SET(ITK_USE_REVIEW_STATISTICS TRUE CACHE BOOLEAN "Seg3D requires the ITK Review directory for proper filter operations." FORCE)
+  SET(ITK_INSTALL_NO_DEVELOPMENT 1)
+  SET(ITK_INSTALL_NO_RUNTIME 1)
+  SET(ITK_INSTALL_NO_DOCUMENTATION 1)
+  SET(ITK_INSTALL_NO_LIBRARIES 1)
+  SET(ITK_USE_SYSTEM_GDCM 1 CACHE BOOL "" FORCE)
+  ADD_SUBDIRECTORY(Externals/itk)
+  INCLUDE_DIRECTORIES(${SCI_ITK_INCLUDE})
+ENDIF(USE_SYSTEM_LIBRARIES)
+
+##################################################
+# ADDING MRC2000
+##################################################
+
+MESSAGE(STATUS "Configuring MRC2000")
+ADD_SUBDIRECTORY(Externals/MRC2000IO)
+INCLUDE_DIRECTORIES(${SCI_MRC2000IO_INCLUDE})
+
+##################################################
+# ADDING PYTHON
+##################################################
+
+OPTION(BUILD_WITH_PYTHON "Build with python support." ON)
+IF(BUILD_WITH_PYTHON)
+  MESSAGE(STATUS "Configuring python")
+
+  IF(USE_SYSTEM_LIBRARIES)
+    SET(Python_ADDITIONAL_VERSIONS 3.2 3.1 3.0)
+    FIND_PACKAGE(PythonLibs)
+    INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_DIRS})
+    SET(SCI_PYTHON_LIBRARY ${PYTHON_LIBRARIES})
+  ELSE(USE_SYSTEM_LIBRARIES)
+    ADD_DEFINITIONS(-DBUILD_WITH_PYTHON 
+      -DPy_NO_ENABLE_SHARED 
+      -DBOOST_PYTHON_STATIC_MODULE
+      -DBOOST_PYTHON_STATIC_LIB)
+    ADD_SUBDIRECTORY(Externals/python)
+    INCLUDE_DIRECTORIES(${SCI_PYTHON_INCLUDE})
+  ENDIF(USE_SYSTEM_LIBRARIES)
+
+  # Generate the python functions registration file
+  MESSAGE(STATUS "Configuring action python wrapper functions")
+  INCLUDE(CMake/GenerateActionPythonWrapper.cmake)
+  GENERATE_ACTION_PYTHON_WRAPPER_REGISTRATION_FILE()
+ENDIF(BUILD_WITH_PYTHON)
+
+##################################################
+# ADDING BOOST
+##################################################
+
+MESSAGE(STATUS "Configuring boost")
 
-ADD_SUBDIRECTORY(Externals)
+IF(USE_SYSTEM_LIBRARIES)
+  IF(BUILD_WITH_PYTHON)
+    SET(boost_python_components python-py32)
+  ELSE(BUILD_WITH_PYTHON)
+    SET(boost_python_components )
+  ENDIF(BUILD_WITH_PYTHON)
+  FIND_PACKAGE(Boost 1.36.0 REQUIRED filesystem regex system thread date_time ${boost_python_components})
+  INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
+  SET(SCI_BOOST_LIBRARY ${Boost_LIBRARIES})
+ELSE(USE_SYSTEM_LIBRARIES)
+  ADD_DEFINITIONS(-DBOOST_ALL_NO_LIB)  
+  ADD_SUBDIRECTORY(Externals/boost)
+  INCLUDE_DIRECTORIES(${SCI_BOOST_INCLUDE})  
+ENDIF(USE_SYSTEM_LIBRARIES)
+
+MESSAGE(STATUS "Configuring Seg3D2")
 
 ###########################################
 # SETUP FOR DEBUG BUILDS
@@ -294,26 +492,6 @@ INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
 # Set the include paths
 ###########################################
 
-INCLUDE_DIRECTORIES(${QT_INCLUDE_DIR})
-INCLUDE_DIRECTORIES(${SCI_BOOST_INCLUDE})
-INCLUDE_DIRECTORIES(${SCI_ZLIB_INCLUDE})
-INCLUDE_DIRECTORIES(${SCI_LIBPNG_INCLUDE})
-INCLUDE_DIRECTORIES(${SCI_TEEM_INCLUDE})
-INCLUDE_DIRECTORIES(${SCI_GLEW_INCLUDE})
-INCLUDE_DIRECTORIES(${SCI_GDCM_INCLUDE})
-INCLUDE_DIRECTORIES(${SCI_FREETYPE_INCLUDE})
-INCLUDE_DIRECTORIES(${SCI_ITK_INCLUDE})
-INCLUDE_DIRECTORIES(${SCI_TINYXML_INCLUDE})
-INCLUDE_DIRECTORIES(${SCI_MATLABIO_INCLUDE})
-INCLUDE_DIRECTORIES(${SCI_SQLITE_INCLUDE})
-INCLUDE_DIRECTORIES(${SCI_MRC2000IO_INCLUDE})
-
-IF(BUILD_WITH_PYTHON)
-  INCLUDE_DIRECTORIES(${SCI_PYTHON_INCLUDE})
-  ADD_DEFINITIONS(-DPy_NO_ENABLE_SHARED)
-  INCLUDE(CMake/GenerateActionPythonWrapper.cmake)
-ENDIF(BUILD_WITH_PYTHON)
-
 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
 
 ###########################################
@@ -325,10 +503,6 @@ INCLUDE(CMake/Core.cmake)
 INCLUDE(CMake/RegisterClass.cmake)
 
 ###########################################
-
-SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake/Modules")
-
-###########################################
 # Application layers:
 #  Core - Core functionality
 #  Application - All pieces need for the
@@ -415,14 +589,6 @@ ENDIF(SEG3D_BUILD_INTERFACE)
 MESSAGE(STATUS "Configuring Seg3D registered functions")
 GENERATE_REGISTRATION_FILES()
 
-###########################################
-# Generate the python functions registration file
-###########################################
-
-IF(BUILD_WITH_PYTHON)
-  MESSAGE(STATUS "Configuring action python wrapper functions")
-  GENERATE_ACTION_PYTHON_WRAPPER_REGISTRATION_FILE()
-ENDIF(BUILD_WITH_PYTHON)
 
 ###########################################
 # Bootstrap
diff --git a/src/Core/Action/ActionInfo.cc b/src/Core/Action/ActionInfo.cc
index 916da8f..f0344d0 100644
--- a/src/Core/Action/ActionInfo.cc
+++ b/src/Core/Action/ActionInfo.cc
@@ -29,7 +29,7 @@
 #include <iostream>
 
 // TinyXML includes
-#include <Externals/tinyxml/tinyxml.h>
+#include <tinyxml.h>
 
 // Core includes
 #include <Core/Utils/Exception.h>
diff --git a/src/Core/State/StateHandler.cc b/src/Core/State/StateHandler.cc
index b443fe1..867ac31 100644
--- a/src/Core/State/StateHandler.cc
+++ b/src/Core/State/StateHandler.cc
@@ -30,7 +30,7 @@
 #include <queue>
 
 // TinyXML includes
-#include <Externals/tinyxml/tinyxml.h>
+#include <tinyxml.h>
 
 // Core includes
 #include <Core/State/StateHandler.h>
@@ -305,7 +305,7 @@ bool StateHandler::load_states( const StateIO& state_io )
 			state_value_str_map[ this->get_statehandler_id() + "::" + stateid ] = state_value_str;			
 		}
 
-		state_element = state_element->NextSiblingElement( STATE_ELEMENT_NAME );
+		state_element = state_element->NextSiblingElement( STATE_ELEMENT_NAME.c_str() );
 	}
 	
 	if ( !success )
@@ -454,11 +454,11 @@ bool StateHandler::save_states( StateIO& state_io )
 	TiXmlElement* sh_element;
 	if ( this->private_->do_not_save_id_number_ )
 	{
-		sh_element = new TiXmlElement( this->get_statehandler_id_base() );
+		sh_element = new TiXmlElement( this->get_statehandler_id_base().c_str() );
 	}
 	else
 	{
-		sh_element = new TiXmlElement( this->get_statehandler_id() );
+		sh_element = new TiXmlElement( this->get_statehandler_id().c_str() );
 	}
 
 	state_io.get_current_element()->LinkEndChild( sh_element );
diff --git a/src/Externals/CMakeLists.txt b/src/Externals/CMakeLists.txt
deleted file mode 100755
index 72f4a83..0000000
--- a/src/Externals/CMakeLists.txt
+++ /dev/null
@@ -1,137 +0,0 @@
-#
-#  For more information, please see: http://software.sci.utah.edu
-# 
-#  The MIT License
-# 
-#  Copyright (c) 2009 Scientific Computing and Imaging Institute,
-#  University of Utah.
-# 
-#  
-#  Permission is hereby granted, free of charge, to any person obtaining a
-#  copy of this software and associated documentation files (the "Software"),
-#  to deal in the Software without restriction, including without limitation
-#  the rights to use, copy, modify, merge, publish, distribute, sublicense,
-#  and/or sell copies of the Software, and to permit persons to whom the
-#  Software is furnished to do so, subject to the following conditions:
-# 
-#  The above copyright notice and this permission notice shall be included
-#  in all copies or substantial portions of the Software. 
-# 
-#  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-#  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-#  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-#  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-#  DEALINGS IN THE SOFTWARE.
-#
-
-MESSAGE(STATUS "Configuring External Packages")
-
-##################################################
-# ADDING ZLIB
-##################################################
-
-MESSAGE(STATUS "Configuring zlib")
-ADD_SUBDIRECTORY(zlib)
-
-##################################################
-# ADDING MATLABIO
-##################################################
-
-MESSAGE(STATUS "Configuring MatlabIO")
-ADD_SUBDIRECTORY(MatlabIO)
-
-##################################################
-# ADDING LIBPNG
-##################################################
-
-MESSAGE(STATUS "Configuring libpng")
-ADD_SUBDIRECTORY(libpng)
-
-##################################################
-# ADDING TEEM
-##################################################
-
-# Teem depends on libpng and zlib, so make sure 
-# that these projects are included before Teem.
-
-MESSAGE(STATUS "Configuring teem")
-ADD_SUBDIRECTORY(teem)
-
-##################################################
-# ADDING GLEW
-##################################################
-
-MESSAGE(STATUS "Configuring glew")
-ADD_SUBDIRECTORY(glew)
-
-##################################################
-# ADDING FREETYPE
-##################################################
-
-MESSAGE(STATUS "Configuring freetype")
-ADD_SUBDIRECTORY(freetype)
-
-##################################################
-# ADDING TINYXML
-##################################################
-
-MESSAGE(STATUS "Configuring tinyxml")
-ADD_SUBDIRECTORY(tinyxml)
-
-##################################################
-# ADDING TINYXML
-##################################################
-
-MESSAGE(STATUS "Configuring SQLite")
-ADD_SUBDIRECTORY(sqlite)
-
-##################################################
-# ADDING GDCM
-##################################################
-
-MESSAGE(STATUS "Configuring GDCM")
-ADD_SUBDIRECTORY(gdcm)
-
-##################################################
-# ADDING ITK
-##################################################
-
-MESSAGE(STATUS "Configuring insight toolkit")
-
-# Force ITK not to install any libraries, header
-# files etc. Because we don't need that stuff
-
-SET(ITK_INSTALL_NO_DEVELOPMENT 1)
-SET(ITK_INSTALL_NO_RUNTIME 1)
-SET(ITK_INSTALL_NO_DOCUMENTATION 1)
-SET(ITK_INSTALL_NO_LIBRARIES 1)
-SET(ITK_USE_SYSTEM_GDCM 1 CACHE BOOL "" FORCE)
-INCLUDE_DIRECTORIES(${SCI_GDCM_INCLUDE})
-ADD_SUBDIRECTORY(itk)
-
-##################################################
-# ADDING MRC2000
-##################################################
-
-MESSAGE(STATUS "Configuring MRC2000")
-ADD_SUBDIRECTORY(MRC2000IO)
-
-##################################################
-# ADDING PYTHON
-##################################################
-
-IF(BUILD_WITH_PYTHON)
-  MESSAGE(STATUS "Configuring python")
-  ADD_SUBDIRECTORY(python)
-ENDIF(BUILD_WITH_PYTHON)
-
-##################################################
-# ADDING BOOST
-##################################################
-
-MESSAGE(STATUS "Configuring boost")
-ADD_SUBDIRECTORY(boost)
-
-MESSAGE(STATUS "Configuring Seg3D2")



Archive powered by MHonArc 2.6.18.

Top of page