Updates will be applied today, at 4 pm EDT (UTC-0400). No interruption, and site should remain available.

vtkXdmf3DataSet.h 7.39 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/*=========================================================================

  Program:   Visualization Toolkit
  Module:    vtkXdmf3DataSet.h
  Language:  C++

  Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen
  All rights reserved.
  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notice for more information.

=========================================================================*/
16 17 18 19 20 21 22 23 24 25
/**
 * @class   vtkXdmf3DataSet
 * @brief   dataset level translation between xdmf3 and vtk
 *
 * This class holds static methods that translate the five atomic data
 * types between vtk and xdmf3.
 *
 * This file is a helper for the vtkXdmf3Reader and vtkXdmf3Writer and
 * not intended to be part of VTK public API
*/
26

27 28
#ifndef vtkXdmf3DataSet_h
#define vtkXdmf3DataSet_h
29 30 31 32 33 34

#include "vtkIOXdmf3Module.h" // For export macro
#include "XdmfSharedPtr.hpp"
#include <string> //Needed only for XdmfArray::getName :(

class vtkXdmf3ArraySelection;
Dave DeMarle's avatar
Dave DeMarle committed
35
class vtkXdmf3ArrayKeeper;
36 37 38 39
class XdmfArray;
class vtkDataArray;
class XdmfGrid;
class vtkDataObject;
Dave DeMarle's avatar
Dave DeMarle committed
40 41
class XdmfSet;
class vtkDataSet;
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
class XdmfTopologyType;
class XdmfRegularGrid;
class vtkImageData;
class XdmfRectilinearGrid;
class vtkRectilinearGrid;
class XdmfCurvilinearGrid;
class vtkStructuredGrid;
class XdmfUnstructuredGrid;
class vtkUnstructuredGrid;
class vtkPointSet;
class XdmfGraph;
class vtkMutableDirectedGraph;
class vtkDirectedGraph;
class XdmfDomain;

57

58 59 60 61 62 63
class VTKIOXDMF3_EXPORT vtkXdmf3DataSet
{
public:

  // Common

64 65 66
  /**
   * Returns a VTK array corresponding to the Xdmf array it is given.
   */
67 68 69
  static vtkDataArray *XdmfToVTKArray(
    XdmfArray* xArray,
    std::string attrName,//TODO: needed because XdmfArray::getName() misbehaves
Dave DeMarle's avatar
Dave DeMarle committed
70 71
    unsigned int preferredComponents = 0,
    vtkXdmf3ArrayKeeper *keeper=NULL);
72

73 74 75
  /**
   * Populates and Xdmf array corresponding to the VTK array it is given
   */
76 77 78 79 80
  static bool VTKToXdmfArray(
    vtkDataArray *vArray,
    XdmfArray* xArray,
    unsigned int rank = 0, unsigned int *dims = NULL);

81 82 83 84
  /**
   * Populates the given VTK DataObject's attribute arrays with the selected
   * arrays from the Xdmf Grid
   */
85 86 87 88
  static void XdmfToVTKAttributes(
    vtkXdmf3ArraySelection *fselection,
    vtkXdmf3ArraySelection *cselection,
    vtkXdmf3ArraySelection *pselection,
Dave DeMarle's avatar
Dave DeMarle committed
89 90
    XdmfGrid *grid, vtkDataObject *dObject,
    vtkXdmf3ArrayKeeper *keeper=NULL);
91

92 93 94 95
  /**
   * Populates the given Xdmf Grid's attribute arrays with the selected
   * arrays from the VTK DataObject
   */
96 97
  static void VTKToXdmfAttributes(vtkDataObject *dObject, XdmfGrid *grid);

98 99 100 101
  //@{
  /**
   * Helpers for Unstructured Grid translation
   */
102 103 104
  static unsigned int GetNumberOfPointsPerCell(int vtk_cell_type, bool &fail);
  static int GetVTKCellType(shared_ptr<const XdmfTopologyType> topologyType);
  static int GetXdmfCellType(int vtkType);
105
  //@}
106

107 108 109 110
  //@{
  /**
   * Helper used in VTKToXdmf to set the time in a Xdmf grid
   */
111
  static void SetTime(XdmfGrid *grid, double hasTime, double time);
Dave DeMarle's avatar
Dave DeMarle committed
112
  static void SetTime(XdmfGraph *graph, double hasTime, double time);
113
  //@}
114 115 116

  //vtkXdmf3RegularGrid

117 118 119
  /**
   * Populates the VTK data set with the contents of the Xdmf grid
   */
120 121 122 123 124
  static void XdmfToVTK(
    vtkXdmf3ArraySelection *fselection,
    vtkXdmf3ArraySelection *cselection,
    vtkXdmf3ArraySelection *pselection,
    XdmfRegularGrid *grid,
Dave DeMarle's avatar
Dave DeMarle committed
125 126
    vtkImageData *dataSet,
    vtkXdmf3ArrayKeeper *keeper=NULL);
127

128 129 130
  /**
   * Helper that does topology for XdmfToVTK
   */
131 132
  static void CopyShape(
    XdmfRegularGrid *grid,
Dave DeMarle's avatar
Dave DeMarle committed
133 134
    vtkImageData *dataSet,
    vtkXdmf3ArrayKeeper *keeper=NULL);
135

136 137 138
  /**
   * Populates the Xdmf Grid with the contents of the VTK data set
   */
139 140 141
  static void VTKToXdmf(
    vtkImageData *dataSet,
    XdmfDomain *domain,
142 143
    bool hasTime, double time,
    const char* name = 0);
144 145

  //vtkXdmf3RectilinearGrid
146 147 148
  /**
   * Populates the VTK data set with the contents of the Xdmf grid
   */
149 150 151 152 153
  static void XdmfToVTK(
    vtkXdmf3ArraySelection *fselection,
    vtkXdmf3ArraySelection *cselection,
    vtkXdmf3ArraySelection *pselection,
    XdmfRectilinearGrid *grid,
Dave DeMarle's avatar
Dave DeMarle committed
154 155
    vtkRectilinearGrid *dataSet,
    vtkXdmf3ArrayKeeper *keeper=NULL);
156

157 158 159
  /**
   * Helper that does topology for XdmfToVTK
   */
160 161
  static void CopyShape(
    XdmfRectilinearGrid *grid,
Dave DeMarle's avatar
Dave DeMarle committed
162 163
    vtkRectilinearGrid *dataSet,
    vtkXdmf3ArrayKeeper *keeper=NULL);
164

165 166 167
  /**
   * Populates the Xdmf Grid with the contents of the VTK data set
   */
168 169 170
  static void VTKToXdmf(
    vtkRectilinearGrid *dataSet,
    XdmfDomain *domain,
171 172
    bool hasTime, double time,
    const char* name = 0);
173 174

  //vtkXdmf3CurvilinearGrid
175 176 177
  /**
   * Populates the VTK data set with the contents of the Xdmf grid
   */
178 179 180 181 182
  static void XdmfToVTK(
    vtkXdmf3ArraySelection *fselection,
    vtkXdmf3ArraySelection *cselection,
    vtkXdmf3ArraySelection *pselection,
    XdmfCurvilinearGrid *grid,
Dave DeMarle's avatar
Dave DeMarle committed
183 184
    vtkStructuredGrid *dataSet,
    vtkXdmf3ArrayKeeper *keeper=NULL);
185

186 187 188
  /**
   * Helper that does topology for XdmfToVTK
   */
189 190
  static void CopyShape(
    XdmfCurvilinearGrid *grid,
Dave DeMarle's avatar
Dave DeMarle committed
191 192
    vtkStructuredGrid *dataSet,
    vtkXdmf3ArrayKeeper *keeper=NULL);
193

194 195 196
  /**
   * Populates the Xdmf Grid with the contents of the VTK data set
   */
197 198 199
  static void VTKToXdmf(
    vtkStructuredGrid *dataSet,
    XdmfDomain *domain,
200 201
    bool hasTime, double time,
    const char* name = 0);
202 203

  //vtkXdmf3UnstructuredGrid
204 205 206
  /**
   * Populates the VTK data set with the contents of the Xdmf grid
   */
207 208 209 210 211
  static void XdmfToVTK(
    vtkXdmf3ArraySelection *fselection,
    vtkXdmf3ArraySelection *cselection,
    vtkXdmf3ArraySelection *pselection,
    XdmfUnstructuredGrid *grid,
Dave DeMarle's avatar
Dave DeMarle committed
212 213
    vtkUnstructuredGrid *dataSet,
    vtkXdmf3ArrayKeeper *keeper=NULL);
214

215 216 217
  /**
   * Helper that does topology for XdmfToVTK
   */
218 219
  static void CopyShape(
    XdmfUnstructuredGrid *grid,
Dave DeMarle's avatar
Dave DeMarle committed
220 221
    vtkUnstructuredGrid *dataSet,
    vtkXdmf3ArrayKeeper *keeper=NULL);
222

223 224 225
  /**
   * Populates the Xdmf Grid with the contents of the VTK data set
   */
226 227 228
  static void VTKToXdmf(
    vtkPointSet *dataSet,
    XdmfDomain *domain,
229 230
    bool hasTime, double time,
    const char* name = 0);
231 232

  //vtkXdmf3Graph
233 234 235
  /**
   * Populates the VTK graph with the contents of the Xdmf grid
   */
236 237 238 239 240
  static void XdmfToVTK(
    vtkXdmf3ArraySelection *fselection,
    vtkXdmf3ArraySelection *cselection,
    vtkXdmf3ArraySelection *pselection,
    XdmfGraph *grid,
Dave DeMarle's avatar
Dave DeMarle committed
241 242
    vtkMutableDirectedGraph *dataSet,
    vtkXdmf3ArrayKeeper *keeper=NULL);
243

244 245 246
  /**
   * Populates the Xdmf Grid with the contents of the VTK data set
   */
247 248 249
  static void VTKToXdmf(
    vtkDirectedGraph *dataSet,
    XdmfDomain *domain,
250 251
    bool hasTime, double time,
    const char* name = 0);
Dave DeMarle's avatar
Dave DeMarle committed
252 253 254 255


  //Side Sets

256 257 258 259
  /**
   * Populates the given VTK DataObject's attribute arrays with the selected
   * arrays from the Xdmf Grid
   */
Dave DeMarle's avatar
Dave DeMarle committed
260 261 262 263 264 265
  static void XdmfToVTKAttributes(
/*
    vtkXdmf3ArraySelection *fselection,
    vtkXdmf3ArraySelection *cselection,
    vtkXdmf3ArraySelection *pselection,
*/
Dave DeMarle's avatar
Dave DeMarle committed
266 267
    XdmfSet *grid, vtkDataObject *dObject,
    vtkXdmf3ArrayKeeper *keeper=NULL);
Dave DeMarle's avatar
Dave DeMarle committed
268

269 270 271 272
  /**
   * Extracts numbered subset out of grid (grid corresponds to dataSet),
   * and fills in subSet with it.
   */
Dave DeMarle's avatar
Dave DeMarle committed
273 274 275 276
  static void XdmfSubsetToVTK(
    XdmfGrid *grid,
    unsigned int setnum,
    vtkDataSet *dataSet,
Dave DeMarle's avatar
Dave DeMarle committed
277 278
    vtkUnstructuredGrid *subSet,
    vtkXdmf3ArrayKeeper *keeper=NULL);
Dave DeMarle's avatar
Dave DeMarle committed
279

280 281 282
};

#endif
283
// VTK-HeaderTest-Exclude: vtkXdmf3DataSet.h