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 NewPipeConvertPointSet" 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 "vtkPointSetToPointSetFilter" 22 "vtkPointSetAlgorithm" 23 H_CONTENTS "${H_CONTENTS}") 24 25STRING (REGEX REPLACE 26 "void[ \t]+Execute[ \t]*\\([ \t]*\\)" 27 "int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *)" 28 H_CONTENTS "${H_CONTENTS}") 29 30STRING (REGEX REPLACE 31 "void[ \t]+ExecuteInformation[ \t]*\\([ \t]*\\)" 32 "int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *)" 33 H_CONTENTS "${H_CONTENTS}") 34 35STRING (REGEX REPLACE 36 "void[ \t]+ComputeInputUpdateExtents[ \t]*\\([ \t]*[^)]*\\)" 37 "int RequestUpdateExtent(vtkInformation *, vtkInformationVector **, vtkInformationVector *)" 38 H_CONTENTS "${H_CONTENTS}") 39 40FILE (WRITE ${H_FILE} "${H_CONTENTS}") 41 42#================================================================ 43# Now do the CXX files 44#================================================================ 45 46STRING (REGEX REPLACE 47 "::Execute[ \t]*\\([^{]*{" 48 "::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 vtkPointSet *input = vtkPointSet::SafeDownCast(\n inInfo->Get(vtkDataObject::DATA_OBJECT()));\n vtkPointSet *output = vtkPointSet::SafeDownCast(\n outInfo->Get(vtkDataObject::DATA_OBJECT()));\n" 49 CXX_CONTENTS "${CXX_CONTENTS}") 50 51STRING (REGEX REPLACE 52 "::ExecuteInformation[ \t]*\\([^{]*{" 53 "::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" 54 CXX_CONTENTS "${CXX_CONTENTS}") 55 56STRING (REGEX REPLACE 57 "::ComputeInputUpdateExtents[ \t]*\\([^{]*{" 58 "::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" 59 CXX_CONTENTS "${CXX_CONTENTS}") 60 61# add some useful include files if needed 62IF ("${CXX_CONTENTS}" MATCHES ".*vtkInformation.*") 63 # do not do these replacements multiple times 64 IF (NOT "${CXX_CONTENTS}" MATCHES ".*vtkInformation.h.*") 65 STRING (REGEX REPLACE 66 "vtkObjectFactory.h" 67 "vtkInformation.h\"\n#include \"vtkInformationVector.h\"\n#include \"vtkObjectFactory.h" 68 CXX_CONTENTS "${CXX_CONTENTS}") 69 ENDIF () 70ENDIF () 71 72FILE (WRITE ${CXX_FILE} "${CXX_CONTENTS}") 73