ITK  4.12.0
Insight Segmentation and Registration Toolkit
itkPyVnl.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 
19 #ifndef itkPyVnl_h
20 #define itkPyVnl_h
21 
22 #include <vnl/vnl_vector.h>
23 #include <vnl/vnl_matrix.h>
24 
25 // The python header defines _POSIX_C_SOURCE without a preceding #undef
26 #undef _POSIX_C_SOURCE
27 #undef _XOPEN_SOURCE
28 // For Python 2.7 hypot bug, see https://bugs.python.org/issue11566
29 #include "PatchedPython27pyconfig.h"
30 #include <Python.h>
31 
32 namespace itk
33 {
34 
45 template <typename TElement>
46 class PyVnl
47 {
48 public:
50  typedef PyVnl Self;
51 
53  typedef TElement DataType;
54  typedef vnl_vector<TElement> VectorType;
55  typedef vnl_matrix<TElement> MatrixType;
56 
60  static PyObject * _GetArrayViewFromVnlVector( VectorType * vector);
61 
65  static const VectorType _GetVnlVectorViewFromArray( PyObject *arr, PyObject *shape);
66 
70  static PyObject * _GetArrayViewFromVnlMatrix( MatrixType * matrix);
71 
75  static const MatrixType _GetVnlMatrixViewFromArray( PyObject *arr, PyObject *shape);
76 
77 
78 protected:
79 
80 private:
81  PyVnl(const Self&); // Purposely not implemented.
82  void operator=(const Self&); // Purposely not implemented.
83 };
84 
85 } // namespace itk
86 
87 #ifndef ITK_MANUAL_INSTANTIATION
88 #include "itkPyVnl.hxx"
89 #endif
90 
91 #endif // _itkPyVnl_h
PyVnl Self
Definition: itkPyVnl.h:50
void operator=(const Self &)
TElement DataType
Definition: itkPyVnl.h:53
static const VectorType _GetVnlVectorViewFromArray(PyObject *arr, PyObject *shape)
vnl_matrix< TElement > MatrixType
Definition: itkPyVnl.h:55
static const MatrixType _GetVnlMatrixViewFromArray(PyObject *arr, PyObject *shape)
static PyObject * _GetArrayViewFromVnlVector(VectorType *vector)
PyVnl(const Self &)
vnl_vector< TElement > VectorType
Definition: itkPyVnl.h:54
static PyObject * _GetArrayViewFromVnlMatrix(MatrixType *matrix)
Helper class get views of VNL data buffers in python arrays and back.
Definition: itkPyVnl.h:46