ITK  4.13.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 
46 template <typename TElement>
47 class PyVnl
48 {
49 public:
51  typedef PyVnl Self;
52 
54  typedef TElement DataType;
55  typedef vnl_vector<TElement> VectorType;
56  typedef vnl_matrix<TElement> MatrixType;
57 
61  static PyObject * _GetArrayViewFromVnlVector( VectorType * vector);
62 
66  static const VectorType _GetVnlVectorFromArray( PyObject *arr, PyObject *shape);
67 
71  static PyObject * _GetArrayViewFromVnlMatrix( MatrixType * matrix);
72 
76  static const MatrixType _GetVnlMatrixFromArray( PyObject *arr, PyObject *shape);
77 
78 
79 protected:
80 
81 private:
82  PyVnl(const Self&); // Purposely not implemented.
83  void operator=(const Self&); // Purposely not implemented.
84 };
85 
86 } // namespace itk
87 
88 #ifndef ITK_MANUAL_INSTANTIATION
89 #include "itkPyVnl.hxx"
90 #endif
91 
92 #endif // _itkPyVnl_h
PyVnl Self
Definition: itkPyVnl.h:51
void operator=(const Self &)
static const MatrixType _GetVnlMatrixFromArray(PyObject *arr, PyObject *shape)
TElement DataType
Definition: itkPyVnl.h:54
static const VectorType _GetVnlVectorFromArray(PyObject *arr, PyObject *shape)
vnl_matrix< TElement > MatrixType
Definition: itkPyVnl.h:56
static PyObject * _GetArrayViewFromVnlVector(VectorType *vector)
PyVnl(const Self &)
vnl_vector< TElement > VectorType
Definition: itkPyVnl.h:55
static PyObject * _GetArrayViewFromVnlMatrix(MatrixType *matrix)
Helper class get views of VNL data buffers in python arrays and back.
Definition: itkPyVnl.h:47