[Insight-developers] Perl script to rename

Will Schroeder will.schroeder@kitware.com
Tue, 13 Feb 2001 21:08:27 -0500


--=====================_736705156==_
Content-Type: text/plain; charset="us-ascii"

Hi Folks-

If you have some code outside of the repository, here is a Perl script that
will rename classes and hopefully bring you into synch with Insight.

Will
--=====================_736705156==_
Content-Type: text/plain; charset="us-ascii"
Content-Disposition: attachment; filename="rename.pl"

# A simple perl script modified vtk files for std::ostream usage
# (i.e., preparation for ANSI C++).
# Run the file in a directory against */h *.cxx
#
# Changes "ostream" to "vtkOstream" and "endl" to "vtkEndl". These
# are typedef'd and defined in vtkOstream.h.
#

# The input record separator is defined by Perl global 
# variable $/.  It can be anything, including multiple 
# characters.  Normally it is "\n", newline.  Here, we
# say there is no record separator, so the whole file
# is read as one long record, newlines included.    
undef $/;

# Process each file, making necessary substitutions
    foreach $file (@ARGV) {
        if (! open(INPUT,"<$file") ) {
            print STDERR "Can't open input file $bakfile\n";
            next;
        }
        # Read input file as one long record.        
        $data=<INPUT>;
        close INPUT;

        $data =~ s/AffineMutualInformationVW/ParzenWindowAffineMutualInformationMetric/g;
        $data =~ s/AffineMutualInformation/AffineMutualInformationMetric/g;
        $data =~ s/ByteSwap/ByteSwapper/g;
        $data =~ s/CurvatureFlow/CurvatureFlowImageFilter/g;
        $data =~ s/DataAccessorRGBtoBlue/BlueDataAccessor/g;
        $data =~ s/DataAccessorRGBtoGreen/GreenDataAccessor/g;
        $data =~ s/DataAccessorRGBtoRed/RedDataAccessor/g;
        $data =~ s/DerivativeHalfBackwardOperator/BackwardDifferenceOperator/g;
        $data =~ s/DerivativeHalfForwardOperator/ForwardDifferenceOperator/g;
        $data =~ s/EntropyDerivativeFunction/EntropyPreservingGradientMagnitudeImageFunction/g;
        $data =~ s/EvolveLevelSet/LevelSetImageFilter/g;
        $data =~ s/ExtensionVelocities/ExtensionVelocitiesImageFilter/g;
        $data =~ s/ExtractMeshConnectedRegions/ConnectedRegionsMeshFilter/g;
        $data =~ s/FastMarchExtension/FastMarchingExtensionImageFilter/g;
        $data =~ s/FastMarching/FastMarchingImageFilter/g;
        $data =~ s/FilterImageAdd/AddImageFilter/g;
        $data =~ s/FilterImageBinary/BinaryImageFilter/g;
        $data =~ s/FilterImageDerivative/DerivativeImageFilter/g;
        $data =~ s/FilterImageDiscreteGaussian/DiscreteGaussianImageFilter/g;
        $data =~ s/FilterImageGradientMagnitude/GradientMagnitudeImageFilter/g;
        $data =~ s/FilterImageMult/MultiplyImageFilter/g;
        $data =~ s/FilterImageRecursiveGaussian/RecursiveGaussianImageFilter/g;
        $data =~ s/FilterImageRecursiveGaussianFirstDerivative/FirstDerivativeRecursiveGaussianImageFilter/g;
        $data =~ s/FilterImageRecursiveGaussianSecondDerivative/SecondDerivativeRecursiveGaussianImageFilter/g;
        $data =~ s/FilterImageSingleOperator/NeighborhoodOperatorImageFilter/g;
        $data =~ s/FilterImageSub/SubtractImageFilter/g;
        $data =~ s/FilterImageTernary/TernaryImageFilter/g;
        $data =~ s/FilterImageTernaryAdd/TernaryAddImageFilter/g;
        $data =~ s/FilterImageTernaryModulus/TernaryMagnitudeImageFilter/g;
        $data =~ s/FilterImageTernaryModulusSquare/TernaryMagnitudeSquaredImageFilter/g;
        $data =~ s/FilterImageToImage/ImageToImageFilter/g;
        $data =~ s/FilterImageWatershedLevelAdaptor/RelabelWatershedImageFilter/g;
        $data =~ s/FilterImageWatershedSegment/WatershedImageFilter/g;
        $data =~ s/FilterMeshToMesh/MeshToMeshFilter/g;
        $data =~ s/GeodesicActiveContours/GeodesicActiveContourImageFilter/g;
        $data =~ s/ImageMoments/ImageMomentsCalculator/g;
        $data =~ s/ImageRegionSimpleIterator/SimpleImageRegionIterator/g;
        $data =~ s/ImageScalarRegionIterator/ScalarImageRegionIterator/g;
        $data =~ s/ImportImage/ImportImageFilter/g;
        $data =~ s/LevelSetShapeDetection/ShapeDetectionLevelSetFilter/g;
        $data =~ s/LinearInterpolateFunction/LinearInterpolateImageFunction/g;
        $data =~ s/LocateLevelSet/LevelSetNeighborhoodExtractor/g;
        $data =~ s/MRFLabeller/MRFImageFilter/g;
        $data =~ s/MeshTypeDefaultDynamic/DefaultDynamicMeshType/g;
        $data =~ s/MeshTypeDefault/DefaultStaticMeshType/g;
        $data =~ s/MutualInformation/MutualInformationImageMetric/g;
        $data =~ s/MutualInformationRigidRegistration/MutualInformationAffineRegistrator/g;
        $data =~ s/MutualInformationRigidRegistrationVW/ParzenWindowMutualInformationAffineRegistrator/g;
        $data =~ s/NonThreadedShrinkImage/NonThreadedShrinkImageFilter/g;
        $data =~ s/RGBorderKLM/KLMSegmentationBorder/g;
        $data =~ s/RGBorder/SegmentationBorder/g;
        $data =~ s/RGRegionKLM/KLMSegmentationRegion/g;
        $data =~ s/RGRegion/SegmentationRegion/g;
        $data =~ s/RGB/RGBPixel/g;
        $data =~ s/ReadVTKImage/VTKImageReader/g;
        $data =~ s/RegionGrowKLM/KLMRegionGrowImageFilter/g;
        $data =~ s/RegionGrow/RegionGrowImageFilter/g;
        $data =~ s/RegistrationMethod/RegistrationTransform/g;
        $data =~ s/RegistrationMetricProcrustes/ProcrustesRegistrationMetric/g;
        $data =~ s/RegistrationMetric/SimilarityRegistrationMetric/g;
        $data =~ s/RegistrationOptimizerAmoeba/AmoebaOptimizer/g;
        $data =~ s/RegistrationOptimizerConjugateGradient/ConjugateGradientOptimizer/g;
        $data =~ s/RegistrationOptimizerLBFGS/LBFGSOptimizer/g;
        $data =~ s/RegistrationOptimizerLevenbergMarquardt/LevenbergMarquardtOptimizer/g;
        $data =~ s/RegistrationOptimizerNonLinear/NonLinearOptimizer/g;
        $data =~ s/RegistrationOptimizer/Optimizer/g;
        $data =~ s/RegistrationTransformationAffine/AffineTransform/g;
        $data =~ s/ReinitializeLevelSet/ReinitializeLevelSetImageFilter/g;
        $data =~ s/ShrinkImage/ShrinkImageFilter/g;
        $data =~ s/UpwindDerivativeFunction/UpwindDerivativeImageFunction/g;
        $data =~ s/WriteImage/ImageWriter/g;
        $data =~ s/WriteRawImage/RawImageWriter/g;
        $data =~ s/WriteVTKImage/VTKImageWriter/g;
        $data =~ s/FileIO/ImageIO/g;
                
        if (! open(OUTPUT,">$file") ) {
            die "Can't open output file $file\n";            
        }
        print OUTPUT $data;            
        close OUTPUT;

    }
    exit(0); 



--=====================_736705156==_--