• Manuel Grizonnet's avatar
    ENH: rename files with txx extension to hxx · 3a1fd1fc
    Manuel Grizonnet authored
    OTB followed since the beginning the ITK convention and use .txx extension for all
    template classes. Nevertheless, some development tools do not recognize .txx
    file extension. Other tool like GitHub can't do in-browser syntax highlighting for
    txx files I think.
    
    The root problem is the use of the txx which should be changed to hxx (or hpp).
    
    In 2011, after an in-depth discussion near April 20, 2011 on the
    Insight-Developers mailing list, ITK rename all txx files to hxx (and event
    prevent the push of .txx files with a pre-commit hook). It happens is major release v4.
    
    You can find some arguments in the discussion about the change and also in other
    projects related to ITK which applied the same modification, see for instance VXL:
    
    https://github.com/vxl/vxl/issues/209
    
    This commit apply now the same modification for OTB.
    
    I understand that it will change some habit for developers and don't bring new
    features but I think that in general it is better to stay align with ITK guidelines.
    
    In my opinion, it always facilitate the use of OTB and ITK together if we share
    when we can the same code architecture, directory organization, naming
    conventions...
    3a1fd1fc
otbVectorDataToLabelImageCustomFilter.h 5.94 KiB
/*=========================================================================
  Copyright (c) Remi Cresson (IRSTEA). All rights reserved.
     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notices for more information.
=========================================================================*/
#ifndef __gtbVectorDataToLabelImageCustomFilter_h
#define __gtbVectorDataToLabelImageCustomFilter_h
#include "itkImageToImageFilter.h"
#include "itkImageSource.h"
#include "otbMacro.h"
#include "otbImageMetadataInterfaceFactory.h"
#include "otbVectorData.h"
#include "gdal.h"
#include "ogr_api.h"
#include <ogrsf_frmts.h>
namespace otb {
/** \class VectorDataToLabelImageCustomFilter
 *  \brief Burn geometries from the specified VectorData into raster
 *  This class handles burning several input VectorDatas into the
 *  output raster.  The burn values are extracted from a field set by
 *  the user.If no burning field is set, the "FID" is used by default.
 *  A "Burn max value" mode overrides this and makes only the max value
 *  burnt whenever the burning field.
 *  Setting the output raster informations can be done in two ways by:
 *    - Setting the Origin/Size/Spacing of the output image
 *    - Using an existing image as support via SetOutputParametersFromImage(ImageBase)
 *  OGRRegisterAll() method must have been called before applying filter.
 * \ingroup SimpleExtractionTools
template <class TVectorData, class TOutputImage  >
class  ITK_EXPORT VectorDataToLabelImageCustomFilter :
    public itk::ImageSource<TOutputImage>
public:
  /** Standard class typedefs */
  typedef VectorDataToLabelImageCustomFilter                           Self;
  typedef itk::ImageSource<TOutputImage>     Superclass;
  typedef itk::SmartPointer< Self >                           Pointer;
  typedef itk::SmartPointer<const Self>                       ConstPointer;
  /** Run-time type information (and related methods). */
  itkTypeMacro(VectorDataToLabelImageCustomFilter, itk::ImageSource);
  /** Method for creation through the object factory. */
  itkNewMacro(Self);
  typedef TOutputImage                                OutputImageType;
  typedef typename OutputImageType::Pointer           OutputImagePointer;
  typedef typename OutputImageType::SizeType          OutputSizeType;
  typedef typename OutputImageType::IndexType         OutputIndexType;
  typedef typename OutputImageType::SpacingType       OutputSpacingType;
  typedef typename OutputImageType::PointType         OutputOriginType;
  typedef typename OutputImageType::RegionType        OutputImageRegionType;
  typedef typename OutputImageType::PixelType         OutputImagePixelType;
  typedef typename OutputImageType::InternalPixelType OutputImageInternalPixelType;
7172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
/** VectorData typedefs*/ typedef TVectorData VectorDataType; typedef typename VectorDataType::DataTreeType DataTreeType; typedef typename DataTreeType::TreeNodeType InternalTreeNodeType; typedef typename DataTreeType::Pointer DataTreePointerType; typedef typename DataTreeType::ConstPointer DataTreeConstPointerType; typedef itk::ImageBase<OutputImageType::ImageDimension> ImageBaseType; /** Get Nth input VectorData */ const VectorDataType* GetInput(unsigned int idx); /** Method for adding VectorData to rasterize */ virtual void AddVectorData(const VectorDataType* vd); /** Set the size of the output image. */ itkSetMacro(OutputSize, OutputSizeType); /** Get the size of the output image. */ itkGetConstReferenceMacro(OutputSize, OutputSizeType); /** Burn mode */ itkSetMacro(BurnMaxValueMode, bool); itkGetMacro(BurnMaxValueMode, bool); /** Set the origin of the output image. * \sa GetOrigin() */ itkSetMacro(OutputOrigin, OutputOriginType); virtual void SetOutputOrigin(const double origin[2]); virtual void SetOutputOrigin(const float origin[2]); itkGetConstReferenceMacro(OutputOrigin, OutputOriginType); /** Set the spacing (size of a pixel) of the output image. * \sa GetSpacing() */ virtual void SetOutputSpacing(const OutputSpacingType& spacing); virtual void SetOutputSpacing(const double spacing[2]); virtual void SetOutputSpacing(const float spacing[2]); /** Set/Get Output Projection Ref */ itkSetStringMacro(OutputProjectionRef); itkGetStringMacro(OutputProjectionRef); itkSetStringMacro(BurnAttribute); itkGetStringMacro(BurnAttribute); /** Useful to set the output parameters from an existing image*/ void SetOutputParametersFromImage(const ImageBaseType * image); protected: virtual void GenerateData(); VectorDataToLabelImageCustomFilter(); virtual ~VectorDataToLabelImageCustomFilter() override {} virtual void GenerateOutputInformation(); void PrintSelf(std::ostream& os, itk::Indent indent) const; private: VectorDataToLabelImageCustomFilter(const Self&); //purposely not implemented void operator=(const Self&); //purposely not implemented OGRDataSource* m_OGRDataSourcePointer; // Vector Of OGRGeometyH std::vector< OGRGeometryH > m_SrcDataSetGeometries;
141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
std::vector<double> m_BurnValues; std::vector<double> m_FullBurnValues; std::vector<int> m_BandsToBurn; // Field used to extract the burn value std::string m_BurnAttribute; // Burn mode bool m_BurnMaxValueMode; // Default burn value double m_DefaultBurnValue; // Output params std::string m_OutputProjectionRef; OutputSpacingType m_OutputSpacing; OutputOriginType m_OutputOrigin; OutputSizeType m_OutputSize; OutputIndexType m_OutputStartIndex; }; // end of class VectorDataToLabelImageCustomFilter } // end of namespace otb #ifndef OTB_MANUAL_INSTANTIATION #include "otbVectorDataToLabelImageCustomFilter.hxx" #endif #endif