1# This file attempts to convert an old pipeline filter to a new pipeline 2# filter. Run it with a -DCLASS=classname it will use that class name 3# for processing 4 5IF (NOT DEFINED CLASS) 6 MESSAGE ("You did not specify the class to process. Usage: cmake -DCLASS=vtkMyClass -P NewPipeConvertUnstructuredGrid" FATAL_ERROR) 7ENDIF () 8 9FILE (GLOB H_FILE ${CLASS}.h) 10FILE (GLOB CXX_FILE ${CLASS}.cxx) 11 12# read in both files 13FILE (READ ${H_FILE} H_CONTENTS) 14FILE (READ ${CXX_FILE} CXX_CONTENTS) 15 16#================================================================ 17# First do the H file 18#================================================================ 19 20STRING (REGEX REPLACE 21 "vtkUnstructuredGridSource" 22 "vtkUnstructuredGridAlgorithm" 23 H_CONTENTS "${H_CONTENTS}") 24 25STRING (REGEX REPLACE 26 "vtkUnstructuredGridToUnstructuredGridFilter" 27 "vtkUnstructuredGridAlgorithm" 28 H_CONTENTS "${H_CONTENTS}") 29 30STRING (REGEX REPLACE 31 "vtkDataSetToUnstructuredGridFilter" 32 "vtkUnstructuredGridAlgorithm" 33 H_CONTENTS "${H_CONTENTS}") 34 35STRING (REGEX REPLACE 36 "vtkStructuredPointsToUnstructuredGridFilter" 37 "vtkUnstructuredGridAlgorithm" 38 H_CONTENTS "${H_CONTENTS}") 39 40STRING (REGEX REPLACE 41 "vtkGenericDataSetToUnstructuredGridFilter" 42 "vtkUnstructuredGridAlgorithm" 43 H_CONTENTS "${H_CONTENTS}") 44 45STRING (REGEX REPLACE 46 "void[ \t]+Execute[ \t]*\\([ \t]*\\)" 47 "int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *)" 48 H_CONTENTS "${H_CONTENTS}") 49 50STRING (REGEX REPLACE 51 "void[ \t]+ExecuteInformation[ \t]*\\([ \t]*\\)" 52 "int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *)" 53 H_CONTENTS "${H_CONTENTS}") 54 55STRING (REGEX REPLACE 56 "void[ \t]+ComputeInputUpdateExtents[ \t]*\\([ \t]*[^)]*\\)" 57 "int RequestUpdateExtent(vtkInformation *, vtkInformationVector **, vtkInformationVector *)" 58 H_CONTENTS "${H_CONTENTS}") 59 60FILE (WRITE ${H_FILE} "${H_CONTENTS}") 61 62#================================================================ 63# Now do the CXX files 64#================================================================ 65 66STRING (REGEX REPLACE 67 "::Execute[ \t]*\\([^{]*{" 68 "::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" 69 CXX_CONTENTS "${CXX_CONTENTS}") 70 71STRING (REGEX REPLACE 72 "::ExecuteInformation[ \t]*\\([^{]*{" 73 "::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" 74 CXX_CONTENTS "${CXX_CONTENTS}") 75 76STRING (REGEX REPLACE 77 "::ComputeInputUpdateExtents[ \t]*\\([^{]*{" 78 "::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" 79 CXX_CONTENTS "${CXX_CONTENTS}") 80 81# add some useful include files if needed 82IF ("${CXX_CONTENTS}" MATCHES ".*vtkInformation.*") 83 # do not do these replacements multiple times 84 IF (NOT "${CXX_CONTENTS}" MATCHES ".*vtkInformation.h.*") 85 STRING (REGEX REPLACE 86 "vtkObjectFactory.h" 87 "vtkInformation.h\"\n#include \"vtkInformationVector.h\"\n#include \"vtkObjectFactory.h" 88 CXX_CONTENTS "${CXX_CONTENTS}") 89 ENDIF () 90ENDIF () 91 92FILE (WRITE ${CXX_FILE} "${CXX_CONTENTS}") 93