forked from Kitware/VTK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NewPipeConvertUnstructuredGrid.cmake
92 lines (73 loc) · 3.91 KB
/
NewPipeConvertUnstructuredGrid.cmake
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
# This file attempts to convert an old pipeline filter to a new pipeline
# filter. Run it with a -DCLASS=classname it will use that class name
# for processing
IF (NOT DEFINED CLASS)
MESSAGE ("You did not specify the class to process. Usage: cmake -DCLASS=vtkMyClass -P NewPipeConvertUnstructuredGrid" FATAL_ERROR)
ENDIF ()
FILE (GLOB H_FILE ${CLASS}.h)
FILE (GLOB CXX_FILE ${CLASS}.cxx)
# read in both files
FILE (READ ${H_FILE} H_CONTENTS)
FILE (READ ${CXX_FILE} CXX_CONTENTS)
#================================================================
# First do the H file
#================================================================
STRING (REGEX REPLACE
"vtkUnstructuredGridSource"
"vtkUnstructuredGridAlgorithm"
H_CONTENTS "${H_CONTENTS}")
STRING (REGEX REPLACE
"vtkUnstructuredGridToUnstructuredGridFilter"
"vtkUnstructuredGridAlgorithm"
H_CONTENTS "${H_CONTENTS}")
STRING (REGEX REPLACE
"vtkDataSetToUnstructuredGridFilter"
"vtkUnstructuredGridAlgorithm"
H_CONTENTS "${H_CONTENTS}")
STRING (REGEX REPLACE
"vtkStructuredPointsToUnstructuredGridFilter"
"vtkUnstructuredGridAlgorithm"
H_CONTENTS "${H_CONTENTS}")
STRING (REGEX REPLACE
"vtkGenericDataSetToUnstructuredGridFilter"
"vtkUnstructuredGridAlgorithm"
H_CONTENTS "${H_CONTENTS}")
STRING (REGEX REPLACE
"void[ \t]+Execute[ \t]*\\([ \t]*\\)"
"int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *)"
H_CONTENTS "${H_CONTENTS}")
STRING (REGEX REPLACE
"void[ \t]+ExecuteInformation[ \t]*\\([ \t]*\\)"
"int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *)"
H_CONTENTS "${H_CONTENTS}")
STRING (REGEX REPLACE
"void[ \t]+ComputeInputUpdateExtents[ \t]*\\([ \t]*[^)]*\\)"
"int RequestUpdateExtent(vtkInformation *, vtkInformationVector **, vtkInformationVector *)"
H_CONTENTS "${H_CONTENTS}")
FILE (WRITE ${H_FILE} "${H_CONTENTS}")
#================================================================
# Now do the CXX files
#================================================================
STRING (REGEX REPLACE
"::Execute[ \t]*\\([^{]*{"
"::RequestData(\n vtkInformation *vtkNotUsed(request),\n vtkInformationVector **inputVector,\n vtkInformationVector *outputVector)\n{\n // get the info objects\n vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);\n vtkInformation *outInfo = outputVector->GetInformationObject(0);\n\n // get the input and output\n vtkUnstructuredGrid *input = vtkUnstructuredGrid::SafeDownCast(\n inInfo->Get(vtkDataObject::DATA_OBJECT()));\n vtkUnstructuredGrid *output = vtkUnstructuredGrid::SafeDownCast(\n outInfo->Get(vtkDataObject::DATA_OBJECT()));\n"
CXX_CONTENTS "${CXX_CONTENTS}")
STRING (REGEX REPLACE
"::ExecuteInformation[ \t]*\\([^{]*{"
"::RequestInformation(\n vtkInformation *vtkNotUsed(request),\n vtkInformationVector **inputVector,\n vtkInformationVector *outputVector)\n{\n // get the info objects\n vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);\n vtkInformation *outInfo = outputVector->GetInformationObject(0);\n"
CXX_CONTENTS "${CXX_CONTENTS}")
STRING (REGEX REPLACE
"::ComputeInputUpdateExtents[ \t]*\\([^{]*{"
"::RequestUpdateExtent(\n vtkInformation *vtkNotUsed(request),\n vtkInformationVector **inputVector,\n vtkInformationVector *outputVector)\n{\n // get the info objects\n vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);\n vtkInformation *outInfo = outputVector->GetInformationObject(0);\n"
CXX_CONTENTS "${CXX_CONTENTS}")
# add some useful include files if needed
IF ("${CXX_CONTENTS}" MATCHES ".*vtkInformation.*")
# do not do these replacements multiple times
IF (NOT "${CXX_CONTENTS}" MATCHES ".*vtkInformation.h.*")
STRING (REGEX REPLACE
"vtkObjectFactory.h"
"vtkInformation.h\"\n#include \"vtkInformationVector.h\"\n#include \"vtkObjectFactory.h"
CXX_CONTENTS "${CXX_CONTENTS}")
ENDIF ()
ENDIF ()
FILE (WRITE ${CXX_FILE} "${CXX_CONTENTS}")