File: vtkFieldDataSerializer.h

package info (click to toggle)
vtk9 9.3.0%2Bdfsg1-4
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 267,116 kB
  • sloc: cpp: 2,195,914; ansic: 285,452; python: 104,858; sh: 4,061; yacc: 4,035; java: 3,977; xml: 2,771; perl: 2,189; lex: 1,762; objc: 153; makefile: 150; javascript: 90; tcl: 59
file content (125 lines) | stat: -rw-r--r-- 4,459 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
// SPDX-License-Identifier: BSD-3-Clause
/**
 * @class   vtkFieldDataSerializer
 *
 *
 *  A concrete instance of vtkObject which provides functionality for
 *  serializing and de-serializing field data, primarily used for the purpose
 *  of preparing the data for transfer over MPI or other communication
 *  mechanism.
 *
 * @sa
 * vtkFieldData vtkPointData vtkCellData vtkMultiProcessStream
 */

#ifndef vtkFieldDataSerializer_h
#define vtkFieldDataSerializer_h

#include "vtkObject.h"
#include "vtkParallelCoreModule.h" // For export macro

// Forward declarations
VTK_ABI_NAMESPACE_BEGIN
class vtkIdList;
class vtkFieldData;
class vtkDataArray;
class vtkStringArray;
class vtkIntArray;
class vtkMultiProcessStream;

class VTKPARALLELCORE_EXPORT vtkFieldDataSerializer : public vtkObject
{
public:
  static vtkFieldDataSerializer* New();
  vtkTypeMacro(vtkFieldDataSerializer, vtkObject);
  void PrintSelf(ostream& os, vtkIndent indent) override;

  /**
   * Serializes the metadata of the given field data instance, i.e., the
   * number of arrays, the name of each array and their dimensions.
   */
  static void SerializeMetaData(vtkFieldData* fieldData, vtkMultiProcessStream& bytestream);

  /**
   * Given the serialized field metadata in a bytestream, this method extracts
   * the name, datatype and dimensions of each array. The metadata is
   * deserialized on user-supplied, pre-allocated data structures.
   * (1) names -- an array of strings wherein, each element, names[i],
   * corresponds to the name of array i.
   * (2) datatypes -- an array of ints where each element corresponds
   * to the actual primitive type of each array, e.g.,VTK_DOUBLE,VTK_INT, etc.
   * (3) dimensions -- a 2-component array of integers where the first
   * component corresponds to the number of tuples of and the second component
   * corresponds to the number components of array i.
   */
  static void DeserializeMetaData(vtkMultiProcessStream& bytestream, vtkStringArray* names,
    vtkIntArray* datatypes, vtkIntArray* dimensions);

  /**
   * Serializes the given field data (all the field data) into a bytestream.
   */
  static void Serialize(vtkFieldData* fieldData, vtkMultiProcessStream& bytestream);

  /**
   * Serializes the selected tuples from the field data in a byte-stream.
   */
  static void SerializeTuples(
    vtkIdList* tupleIds, vtkFieldData* fieldData, vtkMultiProcessStream& bytestream);

  /**
   * Serializes the given sub-extent of field data of a structured grid
   * in a byte-stream. The field data can be either cell-centered or
   * node-centered depending on what subext and gridExtent actually
   * represents.
   */
  static void SerializeSubExtent(
    int subext[6], int gridExtent[6], vtkFieldData* fieldData, vtkMultiProcessStream& bytestream);

  /**
   * Deserializes the field data from a bytestream to a the given sub-extent.
   * The field data can be either cell-centered or node-centered depending
   * on what subext and gridExtent actually represent.
   */
  static void DeSerializeToSubExtent(
    int subext[6], int gridExtent[6], vtkFieldData* fieldData, vtkMultiProcessStream& bytestream);

  /**
   * Deserializes the field data from a bytestream.
   */
  static void Deserialize(vtkMultiProcessStream& bytestream, vtkFieldData* fieldData);

protected:
  vtkFieldDataSerializer();
  ~vtkFieldDataSerializer() override;

  /**
   * Given an input data array and list of tuples, it extracts the selected
   * tuples in to a new array and returns it.
   */
  static vtkDataArray* ExtractSelectedTuples(vtkIdList* tupleIds, vtkDataArray* inputDataArray);

  /**
   * Given an input data array corresponding to a field on a structured grid,
   * extract the data within the given extent.
   */
  static vtkDataArray* ExtractSubExtentData(
    int subext[6], int gridExtent[6], vtkDataArray* inputDataArray);

  /**
   * Serializes the data array into a bytestream.
   */
  static void SerializeDataArray(vtkDataArray* dataArray, vtkMultiProcessStream& bytestream);

  /**
   * Deserializes the data array from a bytestream
   */
  static void DeserializeDataArray(vtkMultiProcessStream& bytestream, vtkDataArray*& dataArray);

private:
  vtkFieldDataSerializer(const vtkFieldDataSerializer&) = delete;
  void operator=(const vtkFieldDataSerializer&) = delete;
};

VTK_ABI_NAMESPACE_END
#endif /* vtkFieldDataSerializer_h */