vtkMaterialInterfacePieceLoading.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: $RCSfile$
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
22 #ifndef vtkMaterialInterfacePieceLoading_h
23 #define vtkMaterialInterfacePieceLoading_h
24 
25 #include "vtkPVVTKExtensionsFiltersMaterialInterfaceModule.h" //needed for exports
26 #include "vtkSystemIncludes.h"
27 
28 #include "vtkType.h"
29 #include <cassert>
30 #include <iostream>
31 #include <vector>
32 
34 {
35 public:
36  enum
37  {
38  ID = 0,
39  LOADING = 1,
40  SIZE = 2
41  };
42  vtkMaterialInterfacePieceLoading() { this->Initialize(-1, 0); }
43  ~vtkMaterialInterfacePieceLoading() { this->Initialize(-1, 0); }
44  void Initialize(int id, vtkIdType loading)
45  {
46  this->Data[ID] = id;
47  this->Data[LOADING] = loading;
48  }
50 
53  void Pack(vtkIdType* buf)
54  {
55  buf[ID] = this->Data[ID];
56  buf[LOADING] = this->Data[LOADING];
57  }
59 
60 
63  void UnPack(vtkIdType* buf)
64  {
65  this->Data[ID] = buf[ID];
66  this->Data[LOADING] = buf[LOADING];
67  }
69 
72  vtkIdType GetId() const { return this->Data[ID]; }
73  vtkIdType GetLoading() const { return this->Data[LOADING]; }
74  void SetLoading(vtkIdType loading) { this->Data[LOADING] = loading; }
76 
80  {
81  assert("Update would make loading negative." && (this->Data[LOADING] + update) >= 0);
82  return this->Data[LOADING] += update;
83  }
85 
86 
90  {
91  return this->Data[ID] < other.Data[ID];
92  }
94  {
95  return this->Data[ID] == other.Data[ID];
96  }
97 
98 private:
99  vtkIdType Data[SIZE];
100 };
102 std::ostream& operator<<(std::ostream& sout, const vtkMaterialInterfacePieceLoading& fp);
104 void PrintPieceLoadingHistogram(std::vector<std::vector<vtkIdType> >& pla);
105 #endif
106 
107 
108 // VTK-HeaderTest-Exclude: vtkMaterialInterfacePieceLoading.h
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
void Initialize(int id, vtkIdType loading)
VTKPVVTKEXTENSIONSFILTERSMATERIALINTERFACE_EXPORT void PrintPieceLoadingHistogram(std::vector< std::vector< vtkIdType > > &pla)
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)