Skip to content

Commit

Permalink
Merge branch 'master' of github.com:PDAL/PDAL
Browse files Browse the repository at this point in the history
  • Loading branch information
mpgerlek committed Mar 13, 2012
2 parents dd95d7d + 11c08ed commit 47d262f
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 6 deletions.
5 changes: 4 additions & 1 deletion CMakeLists.txt
Expand Up @@ -422,8 +422,11 @@ if(WITH_PYTHON)
if(PYTHONLIBS_FOUND)
set(CMAKE_REQUIRED_LIBRARIES ${PYTHON_LIBRARY})
include_directories(${PYTHON_INCLUDE_DIR})
add_definitions(-DHAVE_PYTHON=1)
add_definitions(-DHAVE_PYTHON=1)
set(PDAL_HAVE_PYTHON 1)

find_package(NumPy)
include_directories(${NUMPY_INCLUDE_DIR})
message(STATUS "Found Python: ${PYTHON_LIBRARY}")
endif()
endif()
Expand Down
36 changes: 36 additions & 0 deletions cmake/modules/FindNumPy.cmake
@@ -0,0 +1,36 @@
# - Try to find the Python module NumPy
#
# This module defines:
# NUMPY_INCLUDE_DIR: include path for arrayobject.h

# Copyright (c) 2009-2012 Arnaud Barré <arnaud.barre@gmail.com>
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.

MESSAGE(STATUS "Searching for NumPy library")

IF (NUMPY_INCLUDE_DIR)
SET(NUMPY_FIND_QUIETLY TRUE)
endif (NUMPY_INCLUDE_DIR)

# To set the variables PYTHON_EXECUTABLE
FIND_PACKAGE(PythonInterp REQUIRED)

# Look for the include path
# WARNING: The variable PYTHON_EXECUTABLE is defined by the script FindPythonInterp.cmake
EXECUTE_PROCESS(COMMAND "${PYTHON_EXECUTABLE}" -c "import numpy; print numpy.get_include(); print numpy.version.version"
OUTPUT_VARIABLE NUMPY_OUTPUT
ERROR_VARIABLE NUMPY_ERROR)

IF(NOT NUMPY_ERROR)
STRING(REPLACE "\n" ";" NUMPY_OUTPUT ${NUMPY_OUTPUT})
LIST(GET NUMPY_OUTPUT 0 NUMPY_INCLUDE_DIR)
LIST(GET NUMPY_OUTPUT 1 NUMPY_VERSION)
ENDIF(NOT NUMPY_ERROR)

INCLUDE(FindPackageHandleStandardArgs)

FIND_PACKAGE_HANDLE_STANDARD_ARGS(NumPy DEFAULT_MSG NUMPY_VERSION NUMPY_INCLUDE_DIR)

MESSAGE(STATUS "Found NumPy at ${NUMPY_INCLUDE_DIR}")
MARK_AS_ADVANCED(NUMPY_INCLUDE_DIR)
10 changes: 5 additions & 5 deletions src/plang/PythonSupport.cpp
Expand Up @@ -45,7 +45,7 @@
#endif

#include <Python.h>
#include <../Lib/site-packages/numpy/core/include/numpy/arrayobject.h>
#include <numpy/arrayobject.h>


namespace pdal { namespace plang {
Expand Down Expand Up @@ -130,7 +130,7 @@ void PythonEnvironment::output_result( PyObject* rslt )

PyArrayObject* obj = PyArray_GETCONTIGUOUS( (PyArrayObject*) rslt );
int ndims = obj->nd;
int* dims = obj->dimensions; // not copying data
npy_intp* dims = obj->dimensions; // not copying data
double* data = (double*) obj->data; // not copying data
int i, j, k = 0;

Expand Down Expand Up @@ -270,10 +270,10 @@ bool PythonMethod::beginChunk(PointBuffer& buffer)


const int nelem = buffer.getNumPoints();
int mydims = { nelem };
npy_intp mydims = { nelem };
int nd = 1;
npy_intp* dims = &mydims;
int stride = schema.getByteSize();
npy_intp stride = schema.getByteSize();
npy_intp* strides = &stride;
int flags = NPY_CARRAY; // NPY_BEHAVED

Expand Down Expand Up @@ -316,7 +316,7 @@ bool PythonMethod::endChunk(PointBuffer& buffer)
assert(PyArray_Check(xarr));
PyArrayObject* arr = (PyArrayObject*)xarr;

int one=0;
npy_intp one=0;
const int pyDataType = getPythonDataType(dim);

if (pyDataType == PyArray_DOUBLE)
Expand Down

0 comments on commit 47d262f

Please sign in to comment.