vtkMaterialInterfacePieceLoading.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
3 // SPDX-License-Identifier: BSD-3-Clause
11 #ifndef vtkMaterialInterfacePieceLoading_h
12 #define vtkMaterialInterfacePieceLoading_h
13 
14 #include "vtkPVVTKExtensionsFiltersMaterialInterfaceModule.h" //needed for exports
15 
16 #include "vtkType.h" // for vtkIdType
17 #include <cassert> // for assert
18 #include <iostream> // for std::ostream
19 #include <vector> // for std::vector
20 
22 {
23 public:
24  enum
25  {
26  ID = 0,
27  LOADING = 1,
28  SIZE = 2
29  };
30  vtkMaterialInterfacePieceLoading() { this->Initialize(-1, 0); }
31  ~vtkMaterialInterfacePieceLoading() { this->Initialize(-1, 0); }
32  void Initialize(int id, vtkIdType loading)
33  {
34  this->Data[ID] = id;
35  this->Data[LOADING] = loading;
36  }
38 
41  void Pack(vtkIdType* buf)
42  {
43  buf[ID] = this->Data[ID];
44  buf[LOADING] = this->Data[LOADING];
45  }
48 
51  void UnPack(vtkIdType* buf)
52  {
53  this->Data[ID] = buf[ID];
54  this->Data[LOADING] = buf[LOADING];
55  }
57 
60  vtkIdType GetId() const { return this->Data[ID]; }
61  vtkIdType GetLoading() const { return this->Data[LOADING]; }
62  void SetLoading(vtkIdType loading) { this->Data[LOADING] = loading; }
64 
68  {
69  assert("Update would make loading negative." && (this->Data[LOADING] + update) >= 0);
70  return this->Data[LOADING] += update;
71  }
74 
78  {
79  return this->Data[ID] < other.Data[ID];
80  }
82  {
83  return this->Data[ID] == other.Data[ID];
84  }
85 
86 private:
87  vtkIdType Data[SIZE];
88 };
90 std::ostream& operator<<(std::ostream& sout, const vtkMaterialInterfacePieceLoading& fp);
92 void PrintPieceLoadingHistogram(std::vector<std::vector<vtkIdType>>& pla);
93 #endif
94 
Data structure that describes a fragment&#39;s loading.
bool operator<(const vtkMaterialInterfacePieceLoading &other) const
Comparison are made by id.
#define VTKPVVTKEXTENSIONSFILTERSMATERIALINTERFACE_EXPORT
int vtkIdType
VTKPVVTKEXTENSIONSFILTERSMATERIALINTERFACE_EXPORT void PrintPieceLoadingHistogram(std::vector< std::vector< vtkIdType >> &pla)
void Initialize(int id, vtkIdType loading)
VTKPVVTKEXTENSIONSFILTERSMATERIALINTERFACE_EXPORT std::ostream & operator<<(std::ostream &sout, const vtkMaterialInterfacePieceLoading &fp)
vtkIdType UpdateLoading(vtkIdType update)
Adds to loading and returns the updated loading.
bool operator==(const vtkMaterialInterfacePieceLoading &other) const
Comparison are made by id.
void Pack(vtkIdType *buf)
Place into a buffer (id, loading)
void UnPack(vtkIdType *buf)
Initialize from a buffer (id, loading)