VTK  9.4.20241016
vtkDataObjectMeshCache.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
3
4#ifndef vtkDataObjectMeshCache_h
5#define vtkDataObjectMeshCache_h
6
7#include "vtkFiltersTemporalModule.h" // Export macro
8
9#include "vtkAlgorithm.h" // for algorithm
10#include "vtkObject.h"
11#include "vtkSmartPointer.h" // for smart pointer
12#include "vtkWeakPointer.h" // for weak pointer
13
14#include <set> // for set
15#include <string> // for string
16
17VTK_ABI_NAMESPACE_BEGIN
18
19class vtkDataObject;
20class vtkDataSet;
22
63class VTKFILTERSTEMPORAL_EXPORT vtkDataObjectMeshCache : public vtkObject
64{
65public:
68 void PrintSelf(ostream& os, vtkIndent indent) override;
69
76 struct Status
77 {
81 bool OriginalDataDefined = false;
85 bool ConsumerDefined = false;
90 bool CacheDefined = false;
94 bool OriginalMeshUnmodified = false;
98 bool ConsumerUnmodified = false;
102 bool AttributesIdsExists = true;
103
107 bool enabled()
108 {
109 return this->OriginalDataDefined && this->ConsumerDefined && this->CacheDefined &&
110 this->ConsumerUnmodified && this->OriginalMeshUnmodified && this->AttributesIdsExists;
111 }
112
117 bool operator==(const Status& other) const
118 {
119 return other.OriginalDataDefined == this->OriginalDataDefined &&
120 other.ConsumerDefined == this->ConsumerDefined &&
121 other.CacheDefined == this->CacheDefined &&
122 other.OriginalMeshUnmodified == this->OriginalMeshUnmodified &&
123 other.ConsumerUnmodified == this->ConsumerUnmodified &&
124 other.AttributesIdsExists == this->AttributesIdsExists;
125 }
126
131 bool operator!=(const Status& other) const { return !(*this == other); }
132
136 void PrintSelf(ostream& os, vtkIndent indent);
137 };
138
143
149
160
168
172 void AddOriginalIds(int attribute, const std::string& name);
173
178 void RemoveOriginalIds(int attribute);
179
186
193
200
205 void UpdateCache(vtkDataObject* newObject);
206
212
216 bool IsSupportedData(vtkDataObject* dataobject) const;
217
218protected:
220 ~vtkDataObjectMeshCache() override = default;
227 void ForwardAttributes(vtkDataSet* input, vtkDataSet* cache, vtkDataSet* output, int attribute,
228 const std::string& name);
232
233private:
235 void operator=(const vtkDataObjectMeshCache&) = delete;
236
240 vtkDataObject* GetOriginalDataObject() const;
241
245 vtkMTimeType GetOriginalMeshTime() const;
246
253 vtkIdType GetNumberOfDataSets(vtkDataObject* dataobject) const;
254
261 bool CacheHasRequestedIds() const;
262
266 void ClearAttributes(vtkDataObject*);
267
272 bool HasConsumerNoInputPort() const;
273
276 vtkWeakPointer<vtkDataSet> OriginalDataSet;
277 vtkWeakPointer<vtkCompositeDataSet> OriginalCompositeDataSet;
278 vtkMTimeType CachedOriginalMeshTime = 0;
279 vtkMTimeType CachedConsumerTime = 0;
280 std::map<int, std::string> OriginalIdsName;
281};
282
283VTK_ABI_NAMESPACE_END
284#endif
Superclass for all sources, filters, and sinks in VTK.
abstract superclass for composite (multi-block or AMR) datasets
vtkDataObjectMeshCache is a class to store and reuse the mesh of a vtkDataSet, while forwarding data ...
vtkSetSmartPointerMacro(Consumer, vtkAlgorithm)
Set the consumer of this cache.
~vtkDataObjectMeshCache() override=default
void CopyCacheToDataObject(vtkDataObject *output)
Fill given dataset with cached data.
void RemoveOriginalIds(int attribute)
Remove ids array name for attribute type.
void ForwardAttributesToDataSet(vtkDataSet *input, vtkDataSet *cache, vtkDataSet *output)
Forward dataset attributes from OriginalDataObject to output.
void ForwardAttributes(vtkDataSet *input, vtkDataSet *cache, vtkDataSet *output, int attribute, const std::string &name)
Forward dataset attributes from OriginalDataObject to output.
void UpdateCache(vtkDataObject *newObject)
Set given dataset as the new Cache.
vtkDataObjectMeshCache()=default
void SetOriginalDataObject(vtkDataObject *original)
Set the original dataobject.
void InvalidateCache()
Invalidate cache.
void ForwardAttributesToComposite(vtkCompositeDataSet *input, vtkCompositeDataSet *output)
Forward dataset attributes from OriginalDataObject to output.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void ClearOriginalIds()
Clear all original ids.
void AddOriginalIds(int attribute, const std::string &name)
Original Ids.
static vtkDataObjectMeshCache * New()
Status GetStatus() const
Compute and returns the current cache status.
bool IsSupportedData(vtkDataObject *dataobject) const
Return true if dataobject is of a supported type.
general representation of visualization data
abstract class to specify dataset behavior
Definition vtkDataSet.h:166
a simple class to control print indentation
Definition vtkIndent.h:108
abstract base class for most VTK objects
Definition vtkObject.h:162
Hold a reference to a vtkObjectBase instance.
a weak reference to a vtkObject.
Structure to handle the current cache status.
bool OriginalMeshUnmodified
True if OriginalDataSet mesh was not modified since last cache update.
void PrintSelf(ostream &os, vtkIndent indent)
Print members.
bool OriginalDataDefined
True if OriginalDataObject is set.
bool operator==(const Status &other) const
Return true if and only if every members are equals.
bool CacheDefined
True if Cache with initialized.
bool ConsumerDefined
True if Consumer is set.
bool operator!=(const Status &other) const
Return true if both object are not equals.
bool ConsumerUnmodified
True if Consumer was not modified since last cache update.
bool AttributesIdsExists
True if attributes ids exists.
bool enabled()
Return true if the cache can safely and meaningfully be used.
int vtkIdType
Definition vtkType.h:315
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:270