I tried to build mshr from git.

I had to modify CMakeCache:

1) my Vtk is installed in a non-standard location
2) it was not finding numpy's headers
2) it was selecting python 3 and not python 2, and then
complaining because no definition of PyInt_FromSsize_t
was provided.

Patch attached. The numpy detection script is copied verbatim from Dolfin's sources.


After that, the compilation is ok, but the demos do not work.

Some of them because the number of arguments of the init functions is wrong
(e.g. simple-csg-3D.py:
    TypeError: new_Box expected 2 arguments, got 6
)

others because of CGAL (e.g. icecream.py):

-----------
marco@pao:~/Programmi/Dolphin/src_from_dorsal/mshr/demo/python (master>)> python icecream.py
Convert to nef polyhedron
Number of vertices: 826
Number of facets: 1648
Cleaning degenerate facets
  Collapsing short edges
  Removing colinear facets by edge flipping
Writing to file: icecream.off
Convert to nef polyhedron
Number of vertices: 826
Number of facets: 1648
Cleaning degenerate facets
  Collapsing short edges
  Removing colinear facets by edge flipping
Traceback (most recent call last):
  File "icecream.py", line 41, in <module>
    m = generate_mesh(geometry, 16, "cgal")
File "/home/marco/local/Fenics/lib64/python2.7/site-packages/mshr.py", line 458, in generate_mesh
    _generate(m, geometry, resolution, backend)
StandardError: CGAL ERROR: assertion violation!
Expr: check_protocoll == 2
File: /home/marco/Programmi/Dolphin/src_from_dorsal/mshr/dorsal_build_dir/CGAL-4.4-installdir/include/CGAL/Polyhedron_incremental_builder_3.h
Line: 286
-------------

Any hint?

Thanks in advance,

Marco
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 72b4424..cfa8518 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -19,6 +19,8 @@ endif()
 # Borrow some cmake modules from cgal
 set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/3rdparty/CGAL-4.4/cmake/modules")
 
+# Add own cmake modules
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules")
 
 # Use C++11
 SET(CMAKE_CXX_FLAGS "-std=c++0x -Wall")
@@ -46,6 +48,51 @@ find_package(GMP REQUIRED)
 # MPFR_IN_CGAL_AUXILIARY - TRUE if the MPFR found is the one distributed with CGAL in the auxiliary folder
 find_package(MPFR REQUIRED)
 
+# Check for VTK
+find_package(VTK REQUIRED)
+set(VTK_VERSION "${VTK_MAJOR_VERSION}.${VTK_MINOR_VERSION}")
+if (VTK_FOUND)
+  if ("${VTK_VERSION}" VERSION_LESS "5.2")
+    set(VTK_FOUND FALSE)
+    message(WARNING "Unable to find VTK (>= 5.2)")
+  else()
+    message(STATUS "Found VTK: ${VTK_DIR} (found version \"${VTK_VERSION}\")")
+  endif()
+endif()
+
+#check for python 2
+find_package(PythonInterp 2)
+
+if (PYTHONINTERP_FOUND)
+  # Get Python include path from Python interpretter
+  execute_process(COMMAND "${PYTHON_EXECUTABLE}" -c
+                         "import distutils.sysconfig, sys; sys.stdout.write(distutils.sysconfig.get_python_inc())"
+                  OUTPUT_VARIABLE _PYTHON_INCLUDE_PATH
+                  RESULT_VARIABLE _PYTHON_INCLUDE_RESULT)
+
+  # Set include path, if returned by interpreter
+  if ("${_PYTHON_INCLUDE_RESULT}" STREQUAL "0")
+    set(PYTHON_INCLUDE_DIR ${_PYTHON_INCLUDE_PATH})
+  endif()
+
+  # Add a search path for Python library based on output from
+  # interpreter
+  set(CMAKE_LIBRARY_PATH_SAVE ${CMAKE_LIBRARY_PATH})
+  if ("${_PYTHON_LIB_RESULT}" STREQUAL "0")
+    set(CMAKE_LIBRARY_PATH ${_PYTHON_LIB_PATH})
+  endif()
+
+  # Find Pythons libs
+  find_package(PythonLibs ${PYTHON_VERSION_STRING} EXACT QUIET REQUIRED)
+  set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH_SAVE})
+endif()
+
+
+# Check for numpy
+find_package(NumPy REQUIRED)
+include_directories(BEFORE ${NUMPY_INCLUDE_DIR})
+include_directories(BEFORE ${PYTHON_INCLUDE_DIR})
+
 add_subdirectory(3rdparty)
 #include_directories(BEFORE ${CGAL_INCLUDE_DIR})
 include_directories(BEFORE ${EXTERNAL_INCLUDE_DIRS})
@@ -170,4 +217,4 @@ if(ENABLE_TESTS)
   add_subdirectory(test)
 else()
   message(STATUS "Testing disabled")
-endif()
\ No newline at end of file
+endif()
diff --git a/cmake/modules/FindNumPy.cmake b/cmake/modules/FindNumPy.cmake
new file mode 100644
index 0000000..ff8c019
--- /dev/null
+++ b/cmake/modules/FindNumPy.cmake
@@ -0,0 +1,80 @@
+# - Find NumPy
+# Find the native NumPy includes
+# This module defines
+#  NUMPY_INCLUDE_DIR, where to find numpy/arrayobject.h, etc.
+#  NUMPY_VERSION, The string version of the numpy version
+#  NUMPY_VERSION_MAJOR, The first number of the numpy version
+#  NUMPY_VERSION_MINOR, The second number of the numpy version
+#  NUMPY_VERSION_MICRO, The third number of the numpy version
+#  NUMPY_FOUND, If false, do not try to use NumPy headers.
+
+#=============================================================================
+# Copyright (C) 2010 Johannes Ring
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. 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.
+#=============================================================================
+
+if(NUMPY_INCLUDE_DIR)
+  # in cache already
+  set(NUMPY_FIND_QUIETLY TRUE)
+endif(NUMPY_INCLUDE_DIR)
+
+execute_process(
+  COMMAND ${PYTHON_EXECUTABLE} -c "import numpy; print numpy.get_include()"
+  OUTPUT_VARIABLE NUMPY_INCLUDE_DIR
+  RESULT_VARIABLE NUMPY_NOT_FOUND
+  OUTPUT_STRIP_TRAILING_WHITESPACE
+  )
+
+if(NUMPY_INCLUDE_DIR)
+  set(NUMPY_FOUND TRUE)
+  set(NUMPY_INCLUDE_DIR ${NUMPY_INCLUDE_DIR} CACHE STRING "NumPy include path")
+else(NUMPY_INCLUDE_DIR)
+  set(NUMPY_FOUND FALSE)
+endif(NUMPY_INCLUDE_DIR)
+
+if(NUMPY_FOUND)
+  execute_process(
+    COMMAND ${PYTHON_EXECUTABLE} -c "import numpy; print numpy.version.version"
+    OUTPUT_VARIABLE NUMPY_VERSION
+    RESULT_VARIABLE NUMPY_NOT_FOUND
+    OUTPUT_STRIP_TRAILING_WHITESPACE
+    )
+  string(REPLACE "." ";" NUMPY_VERSION_LIST ${NUMPY_VERSION})
+  list(GET NUMPY_VERSION_LIST 0 NUMPY_VERSION_MAJOR)
+  list(GET NUMPY_VERSION_LIST 1 NUMPY_VERSION_MINOR)
+  list(GET NUMPY_VERSION_LIST 2 NUMPY_VERSION_MICRO)
+  if(NOT NUMPY_FIND_QUIETLY)
+    message(STATUS "NumPy header version ${NUMPY_VERSION} found")
+  endif(NOT NUMPY_FIND_QUIETLY)
+else(NUMPY_FOUND)
+  if(NUMPY_FIND_REQUIRED)
+    message(FATAL_ERROR "NumPy headers missing")
+  endif(NUMPY_FIND_REQUIRED)
+endif(NUMPY_FOUND)
+
+mark_as_advanced(NUMPY_INCLUDE_DIR, NUMPY_VERSION, NUMPY_VERSION_MAJOR, 
+  NUMPY_VERSION_MINOR, NUMPY_VERSION_MICRO)
_______________________________________________
fenics mailing list
[email protected]
http://fenicsproject.org/mailman/listinfo/fenics

Reply via email to