File: vtkPVTestUtilities.cxx

package info (click to toggle)
paraview 5.1.2%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 221,108 kB
  • ctags: 236,092
  • sloc: cpp: 2,416,026; ansic: 190,891; python: 99,856; xml: 81,001; tcl: 46,915; yacc: 5,039; java: 4,413; perl: 3,108; sh: 1,974; lex: 1,926; f90: 748; asm: 471; pascal: 228; makefile: 198; objc: 83; fortran: 31
file content (155 lines) | stat: -rw-r--r-- 4,023 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/*=========================================================================

  Program:   ParaView
  Module:    vtkPVTestUtilities.cxx

  Copyright (c) Kitware, Inc.
  All rights reserved.
  See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notice for more information.

=========================================================================*/
#include "vtkPVTestUtilities.h"

#include "vtkObjectFactory.h"
#include "vtkType.h"
#include "vtkPolyData.h"
#include "vtkPointData.h"
#include "vtkDataArray.h"
#include "vtkDoubleArray.h"
#include "vtkFloatArray.h"
#include <string>//
#include <vector>//
#include "vtkType.h"//
using std::string;
using std::vector;

vtkStandardNewMacro(vtkPVTestUtilities);

//-----------------------------------------------------------------------------
void vtkPVTestUtilities::Initialize(int argc, char **argv)
{
  this->DataRoot = NULL;
  this->TempRoot = NULL;
  this->Argc=argc;
  this->Argv=argv;
  if (!((argc==0)||(argv==0)))
  {
    this->DataRoot=this->GetDataRoot();
    this->TempRoot=this->GetTempRoot();
  }
}
//-----------------------------------------------------------------------------
char *vtkPVTestUtilities::GetDataRoot()
{
  return this->GetCommandTailArgument("-D");
}
//-----------------------------------------------------------------------------
char *vtkPVTestUtilities::GetTempRoot()
{
  return this->GetCommandTailArgument("-T");
}
//-----------------------------------------------------------------------------
char *vtkPVTestUtilities::GetCommandTailArgument(const char *tag)
{
  for (int i=1; i<this->Argc; ++i)
    {
    if (string(this->Argv[i])==string(tag))
      {
      if ((i+1)<this->Argc)
        {
        return this->Argv[i+1];
        }
      else
        {
        break;
        }
      }
  }
  return 0;
}
//-----------------------------------------------------------------------------
// int vtkPVTestUtilities::CheckForCommandTailArgument(const char *tag)
// {
//   for (int i=1; i<this->Argc; ++i)
//     {
//     if (string(this->Argv[i])==string(tag))
//       {
//       return this->Argv[i+1];
//       }
//     }
//   return 0;
// }
//-----------------------------------------------------------------------------
char vtkPVTestUtilities::GetPathSep()
{
  #if defined _WIN32 && !defined __CYGWIN__
  return '\\';
  #elif defined _WIN64 && !defined __CYGWIN__
  return '\\';
  #else
  return '/';
  #endif
}
//-----------------------------------------------------------------------------
// Concat the data root path to the name supplied.
// The return is a c string that has the correct
// path seperators.
char *vtkPVTestUtilities::GetFilePath(
        const char *base,
        const char *name)
{
  int baseLen=static_cast<int>(strlen(base));
  int nameLen=static_cast<int>(strlen(name));
  int pathLen=baseLen+1+nameLen+1;
  char *filePath=new char[pathLen];
  int i=0;
  for (; i<baseLen; ++i)
    {
    if ( this->GetPathSep()=='\\'
          && base[i]=='/')
      {
      filePath[i]='\\';
      }
    else
      {
      filePath[i]=base[i];
      }
    }
  filePath[i]=this->GetPathSep();
  ++i;
  for (int j=0; j<nameLen; ++j, ++i)
    {
    if ( this->GetPathSep()=='\\'
          && name[j]=='/')
      {
      filePath[i]='\\';
      }
    else
      {
      filePath[i]=name[j];
      }
    }
  filePath[i]='\0';
  return filePath;
}
//-----------------------------------------------------------------------------
void vtkPVTestUtilities::PrintSelf(ostream& os, vtkIndent indent)
{
  this->Superclass::PrintSelf(os,indent);

  os << indent << "argc=" << this->Argc << endl;
  os << indent << "argv=" << this->Argv << endl;
  if(this->DataRoot)
    {
    os << indent << "DataRoot=" << this->DataRoot << endl;
    }
  if(this->TempRoot)
    {
    os << indent << "TempRoot=" << this->TempRoot << endl;
    }
}