ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
vtkDistributedTrivialProducer.cxx
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ParaView
4  Module: vtkPVTrivialProducerStaticInternal.cxx
5 
6  Copyright (c) Kitware, Inc.
7  All rights reserved.
8  See Copyright.txt or http://www.paraview.org/HTML/Copyright.html 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 =========================================================================*/
16 
17 #include "vtkDataSet.h"
18 #include "vtkGarbageCollector.h"
19 #include "vtkInformation.h"
20 #include "vtkInformationVector.h"
21 #include "vtkObjectFactory.h"
22 #include "vtkSmartPointer.h"
23 #include "vtkStreamingDemandDrivenPipeline.h"
24 
25 #include <map>
26 #include <string>
27 #include <vector>
28 
29 //----------------------------------------------------------------------------
30 // Internal Static data structure
31 //----------------------------------------------------------------------------
32 struct vtkPVTrivialProducerStaticInternal
33 {
34  std::map<std::string, vtkSmartPointer<vtkDataObject> > RegisteredDataObjectMap;
35 
36  bool HasKey(const char* key)
37  {
38  if (key == nullptr)
39  {
40  return false;
41  }
42  return this->RegisteredDataObjectMap.find(key) != this->RegisteredDataObjectMap.end();
43  }
44 
45  vtkDataObject* GetDataObject(const char* key)
46  {
47  if (this->HasKey(key))
48  {
49  return this->RegisteredDataObjectMap[key].GetPointer();
50  }
51  return NULL;
52  }
53 
54  void Print(ostream& os, vtkIndent indent)
55  {
56  std::map<std::string, vtkSmartPointer<vtkDataObject> >::iterator iter =
57  this->RegisteredDataObjectMap.begin();
58  while (iter != this->RegisteredDataObjectMap.end())
59  {
60  os << indent << iter->first.c_str() << "\n";
61  iter->second.GetPointer()->PrintSelf(os, indent.GetNextIndent());
62  }
63  }
64 };
65 static vtkPVTrivialProducerStaticInternal Value;
66 vtkPVTrivialProducerStaticInternal* vtkDistributedTrivialProducer::InternalStatic = &Value;
67 //----------------------------------------------------------------------------
68 
70 //----------------------------------------------------------------------------
72 {
73 }
74 
75 //----------------------------------------------------------------------------
77 {
78 }
79 //----------------------------------------------------------------------------
80 void vtkDistributedTrivialProducer::SetGlobalOutput(const char* key, vtkDataObject* output)
81 {
82  if (key)
83  {
84  vtkDistributedTrivialProducer::InternalStatic->RegisteredDataObjectMap[key] = output;
85  cout << "Set Global Dataset for " << key << endl;
86  }
87 }
88 
89 //----------------------------------------------------------------------------
91 {
92  if (key)
93  {
94  vtkDistributedTrivialProducer::InternalStatic->RegisteredDataObjectMap.erase(key);
95  }
96  else
97  {
98  vtkDistributedTrivialProducer::InternalStatic->RegisteredDataObjectMap.clear();
99  }
100 }
101 
102 //----------------------------------------------------------------------------
104 {
105  cout << "Update DS with key " << key << endl;
106  if (vtkDistributedTrivialProducer::InternalStatic->GetDataObject(key))
107  {
108  // vtkDistributedTrivialProducer::InternalStatic->GetDataObject(key)->PrintSelf(cout,
109  // vtkIndent(5));
110  }
111  else
112  {
113  cout << "No dataset" << endl;
114  }
115  this->SetOutput(vtkDistributedTrivialProducer::InternalStatic->GetDataObject(key));
116 }
117 
118 //----------------------------------------------------------------------------
119 void vtkDistributedTrivialProducer::PrintSelf(ostream& os, vtkIndent indent)
120 {
121  this->Superclass::PrintSelf(os, indent);
122  vtkDistributedTrivialProducer::InternalStatic->Print(os, indent);
123 }
#define NULL
void PrintSelf(ostream &os, vtkIndent indent) override
virtual void UpdateFromGlobal(const char *key)
static void SetGlobalOutput(const char *key, vtkDataObject *output)
static void ReleaseGlobalOutput(const char *key)
void SetOutput(vtkDataObject *output) override
QTextStream & endl(QTextStream &stream)
Definition: QtCompat.h:718
vtkStandardNewMacro(vtkDistributedTrivialProducer)
static vtkPVTrivialProducerStaticInternal Value