ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
vtkPVTestUtilities.cxx
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ParaView
4  Module: vtkPVTestUtilities.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 =========================================================================*/
15 #include "vtkPVTestUtilities.h"
16 
17 #include "vtkDataArray.h"
18 #include "vtkDoubleArray.h"
19 #include "vtkFloatArray.h"
20 #include "vtkObjectFactory.h"
21 #include "vtkPointData.h"
22 #include "vtkPolyData.h"
23 #include "vtkType.h"
24 
25 #include <string> //
26 
28 
29 //-----------------------------------------------------------------------------
30 void vtkPVTestUtilities::Initialize(int argc, char** argv)
31 {
32  this->DataRoot = NULL;
33  this->TempRoot = NULL;
34  this->Argc = argc;
35  this->Argv = argv;
36  if (!((argc == 0) || (argv == 0)))
37  {
38  this->DataRoot = this->GetDataRoot();
39  this->TempRoot = this->GetTempRoot();
40  }
41 }
42 //-----------------------------------------------------------------------------
43 char* vtkPVTestUtilities::GetDataRoot()
44 {
45  return this->GetCommandTailArgument("-D");
46 }
47 //-----------------------------------------------------------------------------
48 char* vtkPVTestUtilities::GetTempRoot()
49 {
50  return this->GetCommandTailArgument("-T");
51 }
52 //-----------------------------------------------------------------------------
53 char* vtkPVTestUtilities::GetCommandTailArgument(const char* tag)
54 {
55  for (int i = 1; i < this->Argc; ++i)
56  {
57  if (std::string(this->Argv[i]) == std::string(tag))
58  {
59  if ((i + 1) < this->Argc)
60  {
61  return this->Argv[i + 1];
62  }
63  else
64  {
65  break;
66  }
67  }
68  }
69  return 0;
70 }
71 //-----------------------------------------------------------------------------
72 // int vtkPVTestUtilities::CheckForCommandTailArgument(const char *tag)
73 // {
74 // for (int i=1; i<this->Argc; ++i)
75 // {
76 // if (std::string(this->Argv[i])==std::string(tag))
77 // {
78 // return this->Argv[i+1];
79 // }
80 // }
81 // return 0;
82 // }
83 //-----------------------------------------------------------------------------
84 char vtkPVTestUtilities::GetPathSep()
85 {
86 #if defined _WIN32 && !defined __CYGWIN__
87  return '\\';
88 #elif defined _WIN64 && !defined __CYGWIN__
89  return '\\';
90 #else
91  return '/';
92 #endif
93 }
94 //-----------------------------------------------------------------------------
95 // Concat the data root path to the name supplied.
96 // The return is a c string that has the correct
97 // path separators.
98 char* vtkPVTestUtilities::GetFilePath(const char* base, const char* name)
99 {
100  int baseLen = static_cast<int>(strlen(base));
101  int nameLen = static_cast<int>(strlen(name));
102  int pathLen = baseLen + 1 + nameLen + 1;
103  char* filePath = new char[pathLen];
104  int i = 0;
105  for (; i < baseLen; ++i)
106  {
107  if (this->GetPathSep() == '\\' && base[i] == '/')
108  {
109  filePath[i] = '\\';
110  }
111  else
112  {
113  filePath[i] = base[i];
114  }
115  }
116  filePath[i] = this->GetPathSep();
117  ++i;
118  for (int j = 0; j < nameLen; ++j, ++i)
119  {
120  if (this->GetPathSep() == '\\' && name[j] == '/')
121  {
122  filePath[i] = '\\';
123  }
124  else
125  {
126  filePath[i] = name[j];
127  }
128  }
129  filePath[i] = '\0';
130  return filePath;
131 }
132 //-----------------------------------------------------------------------------
133 void vtkPVTestUtilities::PrintSelf(ostream& os, vtkIndent indent)
134 {
135  this->Superclass::PrintSelf(os, indent);
136 
137  os << indent << "argc=" << this->Argc << endl;
138  os << indent << "argv=" << this->Argv << endl;
139  if (this->DataRoot)
140  {
141  os << indent << "DataRoot=" << this->DataRoot << endl;
142  }
143  if (this->TempRoot)
144  {
145  os << indent << "TempRoot=" << this->TempRoot << endl;
146  }
147 }
std::string name
#define NULL
void PrintSelf(ostream &os, vtkIndent indent) override
void Initialize(int argc, char **argv)
QTextStream & endl(QTextStream &stream)
Definition: QtCompat.h:718
vtkStandardNewMacro(vtkPVTestUtilities)