vtkSMCoreUtilities.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-License-Identifier: BSD-3-Clause
10 #ifndef vtkSMCoreUtilities_h
11 #define vtkSMCoreUtilities_h
12 
13 #include "vtkObject.h"
14 #include "vtkRemotingServerManagerModule.h" //needed for exports
15 
16 #include <optional> // for std::optional
17 #include <string> // for std::string
18 #include <vector> // for std::vector
19 
20 class vtkSMProxy;
22 
24 {
25 public:
26  static vtkSMCoreUtilities* New();
27  vtkTypeMacro(vtkSMCoreUtilities, vtkObject);
28  void PrintSelf(ostream& os, vtkIndent indent) override;
29 
35  static const char* GetFileNameProperty(vtkSMProxy*);
36 
41  static std::vector<std::string> GetFileNameProperties(vtkSMProxy* proxy);
42 
46  static std::string SanitizeName(const char*);
47  static std::string SanitizeName(const std::string& name)
48  {
49  return vtkSMCoreUtilities::SanitizeName(name.c_str());
50  }
51 
53 
57  static bool AdjustRangeForLog(double range[2]);
58  static bool AdjustRangeForLog(double& rmin, double& rmax)
59  {
60  double range[2] = { rmin, rmax };
61  bool retVal = vtkSMCoreUtilities::AdjustRangeForLog(range);
62  rmin = range[0];
63  rmax = range[1];
64  return retVal;
65  }
67 
69 
83  static bool AdjustRange(double range[2]);
84  static bool AdjustRange(double& rmin, double& rmax)
85  {
86  double range[2] = { rmin, rmax };
87  bool retVal = vtkSMCoreUtilities::AdjustRange(range);
88  rmin = range[0];
89  rmax = range[1];
90  return retVal;
91  }
93 
95 
99  static bool AlmostEqual(const double range[2], int ulpsDiff);
100  static bool AlmostEqual(double rmin, double rmax, int ulpsDiff)
101  {
102  double range[2] = { rmin, rmax };
103  return vtkSMCoreUtilities::AlmostEqual(range, ulpsDiff);
104  }
106 
108 
111  static const char* GetInputPropertyName(vtkSMProxy* proxy, int port = 0);
113 
120  static const char* GetStringForCellType(int cellType);
121 
123 
133  vtkSMProxy* proxy, const std::vector<std::string>& files, const char* propName)
134  {
135  vtkSMCoreUtilities::ReplaceReaderFileName(proxy, files, propName, false);
136  }
137  static void ReplaceReaderFileName(vtkSMProxy* proxy, const std::vector<std::string>& files,
138  const char* propName, bool userModifiedName);
140 
146  static std::string FindLargestPrefix(const std::vector<std::string>& files);
147 
152  static std::optional<std::string> RecoverRegistrationName(vtkSMProxy* proxy);
153 
155 
159  static std::string GetFileNameFromFileNameList(const std::vector<std::string>& fileNames);
160  static std::string GetFileNameFromFileNameList(vtkSMStringVectorProperty* stringVectorProperty);
162 
163 protected:
165  ~vtkSMCoreUtilities() override;
166 
167 private:
168  vtkSMCoreUtilities(const vtkSMCoreUtilities&) = delete;
169  void operator=(const vtkSMCoreUtilities&) = delete;
170 };
171 
172 #endif
static bool AdjustRange(double range[2])
Adjust the given range to make it suitable for use with color maps.
static bool AlmostEqual(const double range[2], int ulpsDiff)
Compares val1 and val2 and returns true is the two numbers are within ulpsDiff ULPs (units in last pl...
#define VTKREMOTINGSERVERMANAGER_EXPORT
property representing a vector of strings
void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
collection of utilities.
static bool AdjustRangeForLog(double range[2])
Given a range, converts it to be a valid range to switch to log space.
static std::string SanitizeName(const std::string &name)
static bool AdjustRangeForLog(double &rmin, double &rmax)
Given a range, converts it to be a valid range to switch to log space.
static void ReplaceReaderFileName(vtkSMProxy *proxy, const std::vector< std::string > &files, const char *propName)
Replaces input proxy, which should be a reader proxy, by a new proxy in the pipeline.
static bool AdjustRange(double &rmin, double &rmax)
Adjust the given range to make it suitable for use with color maps.
range
CellTypeInDataSet cellType(vtkDataSet *input)
proxy for a VTK object(s) on a server
Definition: vtkSMProxy.h:140
port
static vtkObject * New()
void operator=(const vtkObjectBase &)
static std::string SanitizeName(const char *)
Sanitize a label/name to be remove spaces, delimiters etc.
static bool AlmostEqual(double rmin, double rmax, int ulpsDiff)
Compares val1 and val2 and returns true is the two numbers are within ulpsDiff ULPs (units in last pl...