00001 00002 /*========================================================================= 00003 00004 Program: Visualization Toolkit 00005 Module: vtkMatlabMexAdapter.h 00006 00007 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00008 All rights reserved. 00009 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00010 00011 This software is distributed WITHOUT ANY WARRANTY; without even 00012 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00013 PURPOSE. See the above copyright notice for more information. 00014 00015 =========================================================================*/ 00016 /*------------------------------------------------------------------------- 00017 Copyright 2009 Sandia Corporation. 00018 Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, 00019 the U.S. Government retains certain rights in this software. 00020 -------------------------------------------------------------------------*/ 00021 00051 #ifndef __vtkMatlabMexAdapter 00052 #define __vtkMatlabMexAdapter 00053 00054 #include "mex.h" // Needed for Matlab mex.h mxArray 00055 #include "matrix.h" // Needed for Matlab matrix.h mxArray 00056 #include "vtkObject.h" 00057 00058 class vtkInformation; 00059 class vtkInformationVector; 00060 class vtkDataArray; 00061 class vtkArray; 00062 class vtkGraph; 00063 class vtkDataArrayCollection; 00064 class vtkArrayData; 00065 class vtkDataObjectCollection; 00066 00067 class VTK_GRAPHICS_EXPORT vtkMatlabMexAdapter : public vtkObject 00068 { 00069 00070 public: 00071 00072 vtkTypeMacro(vtkMatlabMexAdapter, vtkObject); 00073 00074 void PrintSelf(ostream& os, vtkIndent indent); 00075 00076 static vtkMatlabMexAdapter *New(); 00077 00078 //BTX 00080 mxArray* vtkDataArrayToMxArray(vtkDataArray* aa, bool ShallowCopy = false); 00081 00084 vtkDataArray* mxArrayTovtkDataArray(const mxArray* mxa, bool ShallowCopy = false); 00085 00087 mxArray* vtkArrayToMxArray(vtkArray* va); 00088 00090 vtkArray* mxArrayTovtkArray(mxArray* mxa); 00091 00095 mxArray* vtkGraphToMxArray(vtkGraph* ga); 00096 00100 vtkGraph* mxArrayTovtkGraph(mxArray* mxa); 00101 00103 static mxClassID GetMatlabDataType(vtkDataArray* da); 00104 00106 static vtkDataArray* GetVTKDataType(mxClassID cid); 00107 00108 //ETX 00109 00110 protected: 00111 00112 vtkMatlabMexAdapter(); 00113 ~vtkMatlabMexAdapter(); 00114 00115 private: 00116 00117 vtkMatlabMexAdapter(const vtkMatlabMexAdapter&); // Not implemented 00118 void operator=(const vtkMatlabMexAdapter&); // Not implemented 00119 00120 template<typename T> vtkArray* CopymxArrayToVTKArray(mxArray* mxa, int ValueType); 00121 00122 vtkDataArrayCollection* vdac; // Collection of vtkDataArrays that have been converted from R. 00123 vtkArrayData* vad; // Collection of vtkArrays that have been converted from R. 00124 vtkDataObjectCollection* vdoc; // Collection of vtkTables that have been converted from R. 00125 00126 }; 00127 00128 #endif 00129