Disabled external gits
This commit is contained in:
25
cs440-acg/ext/openexr/PyIlmBase/PyImathNumpy/CMakeLists.txt
Normal file
25
cs440-acg/ext/openexr/PyIlmBase/PyImathNumpy/CMakeLists.txt
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
ADD_LIBRARY ( imathnumpymodule ${LIB_TYPE}
|
||||
imathnumpymodule.cpp
|
||||
)
|
||||
|
||||
SET_TARGET_PROPERTIES ( imathnumpymodule
|
||||
PROPERTIES PREFIX "" SUFFIX ".so" BUILD_WITH_INSTALL_RPATH ON
|
||||
)
|
||||
|
||||
INCLUDE_DIRECTORIES (
|
||||
${NUMPY_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
TARGET_LINK_LIBRARIES ( imathnumpymodule
|
||||
PyImath
|
||||
PyIex
|
||||
Imath${ILMBASE_LIBSUFFIX}
|
||||
Iex${ILMBASE_LIBSUFFIX}
|
||||
${Boost_LIBRARIES}
|
||||
)
|
||||
|
||||
INSTALL ( TARGETS imathnumpymodule
|
||||
DESTINATION lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages
|
||||
)
|
||||
|
15
cs440-acg/ext/openexr/PyIlmBase/PyImathNumpy/Makefile.am
Normal file
15
cs440-acg/ext/openexr/PyIlmBase/PyImathNumpy/Makefile.am
Normal file
@@ -0,0 +1,15 @@
|
||||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
pyexec_LTLIBRARIES = imathnumpymodule.la
|
||||
|
||||
imathnumpymodule_la_SOURCES = imathnumpymodule.cpp
|
||||
imathnumpymodule_la_LDFLAGS = -avoid-version -module
|
||||
imathnumpymodule_la_LIBADD = $(top_builddir)/PyImath/libPyImath.la @BOOST_PYTHON_LIBS@
|
||||
|
||||
noinst_HEADERS =
|
||||
|
||||
INCLUDES = @ILMBASE_CXXFLAGS@ \
|
||||
@NUMPY_CXXFLAGS@ \
|
||||
-I$(top_srcdir)/PyImath \
|
||||
-I$(top_builddir) \
|
||||
-I$(top_srcdir)/config
|
@@ -0,0 +1,131 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 1998-2011, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic 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 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
|
||||
// OWNER 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.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <Python.h>
|
||||
#include <boost/python.hpp>
|
||||
#include <PyImath.h>
|
||||
#include <PyImathVec.h>
|
||||
#include <iostream>
|
||||
#include <boost/format.hpp>
|
||||
#include <numpy/arrayobject.h>
|
||||
|
||||
using namespace boost::python;
|
||||
using namespace PyImath;
|
||||
|
||||
static
|
||||
object
|
||||
arrayToNumpy_float(FloatArray &fa)
|
||||
{
|
||||
if (fa.stride() != 1) {
|
||||
throw IEX_NAMESPACE::LogicExc("Unable to make numpy wrapping of strided arrays");
|
||||
}
|
||||
|
||||
npy_intp length = fa.len();
|
||||
float *data = &fa[0];
|
||||
PyObject *a = PyArray_SimpleNewFromData(1,&length,NPY_FLOAT,data);
|
||||
|
||||
if (!a) {
|
||||
throw_error_already_set();
|
||||
}
|
||||
|
||||
object retval = object(handle<>(a));
|
||||
return retval;
|
||||
}
|
||||
|
||||
static
|
||||
object
|
||||
arrayToNumpy_V3f(V3fArray &va)
|
||||
{
|
||||
if (va.stride() != 1) {
|
||||
throw IEX_NAMESPACE::LogicExc("Unable to make numpy wrapping of strided arrays");
|
||||
}
|
||||
|
||||
npy_intp length[2];
|
||||
length[0] = va.len();
|
||||
length[1] = 3;
|
||||
float *data = &va[0].x;
|
||||
PyObject *a = PyArray_SimpleNewFromData(2,length,NPY_FLOAT,data);
|
||||
|
||||
if (!a) {
|
||||
throw_error_already_set();
|
||||
}
|
||||
|
||||
object retval = object(handle<>(a));
|
||||
return retval;
|
||||
}
|
||||
|
||||
static
|
||||
object
|
||||
arrayToNumpy_int(IntArray &va)
|
||||
{
|
||||
if (va.stride() != 1) {
|
||||
throw IEX_NAMESPACE::LogicExc("Unable to make numpy wrapping of strided arrays");
|
||||
}
|
||||
|
||||
npy_intp length = va.len();
|
||||
int *data = &va[0];
|
||||
PyObject *a = PyArray_SimpleNewFromData(1,&length,NPY_INT,data);
|
||||
|
||||
if (!a) {
|
||||
throw_error_already_set();
|
||||
}
|
||||
|
||||
object retval = object(handle<>(a));
|
||||
return retval;
|
||||
}
|
||||
|
||||
BOOST_PYTHON_MODULE(imathnumpy)
|
||||
{
|
||||
handle<> imath(PyImport_ImportModule("imath"));
|
||||
if (PyErr_Occurred()) throw_error_already_set();
|
||||
scope().attr("imath") = imath;
|
||||
|
||||
handle<> numpy(PyImport_ImportModule("numpy"));
|
||||
if (PyErr_Occurred()) throw_error_already_set();
|
||||
scope().attr("numpy") = numpy;
|
||||
|
||||
import_array();
|
||||
|
||||
scope().attr("__doc__") = "Array wrapping module to overlay imath array data with numpy arrays";
|
||||
|
||||
def("arrayToNumpy",&arrayToNumpy_float,
|
||||
"arrayToNumpy(array) - wrap the given FloatArray as a numpy array",
|
||||
(arg("array")));
|
||||
def("arrayToNumpy",&arrayToNumpy_V3f,
|
||||
"arrayToNumpy(array) - wrap the given V3fArray as a numpy array",
|
||||
(arg("array")));
|
||||
def("arrayToNumpy",&arrayToNumpy_int,
|
||||
"arrayToNumpy(array) - wrap the given IntArray as a numpy array",
|
||||
(arg("array")));
|
||||
}
|
Reference in New Issue
Block a user