Commit 03448a92 authored by Cédric Traizet's avatar Cédric Traizet

Merge branch 'remove_spatial_objects' into 'develop'

Remove spatial objects module

See merge request orfeotoolbox/otb!535
parents 61f55ac1 1f671be8
Pipeline #2037 passed with stages
in 71 minutes and 33 seconds
Number of right angles detected 1
Right Angle found in point : [30.5626, 10.5977]
size of the Line list 8
[19, 9] [0, 8]
[18, 39] [19, 20]
[18, 48] [18, 40]
[39, 9] [20, 8]
[20, 39] [21, 20]
[20, 48] [21, 40]
[48, 9] [40, 8]
[48, 35] [40, 24]
<PAMDataset>
<GeoTransform> -1.0050000000000000e+02, 1.0000000000000000e+00, 0.0000000000000000e+00, -5.0500000000000000e+01, 0.0000000000000000e+00, 1.0000000000000000e+00</GeoTransform>
</PAMDataset>
#
# Copyright (C) 2005-2019 Centre National d'Etudes Spatiales (CNES)
#
# This file is part of Orfeo Toolbox
#
# https://www.orfeo-toolbox.org/
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
project(OTBSpatialObjects)
otb_module_impl()
/*
* Copyright (C) 2005-2019 Centre National d'Etudes Spatiales (CNES)
*
* This file is part of Orfeo Toolbox
*
* https://www.orfeo-toolbox.org/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef otbDrawLineSpatialObjectFilter_h
#define otbDrawLineSpatialObjectFilter_h
#include "itkSpatialObjectToImageFilter.h"
#include "otbDrawLineSpatialObjectListFilter.h"
//#include <list>
namespace otb
{
/** \class DrawLineSpatialObjectFilter
* \brief Application of a filter which draw line in a binary image.
*
* This class implements a filter that draws line in a binary image.
* Inputs are a LineSpatialObject and an input image that is used to
* allocate the output image. This filter copies the input image in
* the output image.
*
*
* \ingroup OTBSpatialObjects
*/
template <class TInputImage, class TOutputImage>
class ITK_EXPORT DrawLineSpatialObjectFilter :
//public itk::SpatialObjectToImageFilter< itk::LineSpatialObject<2>, TOutputImage >
public itk::ImageToImageFilter<TInputImage, TOutputImage>
{
public:
/** Extract dimensions as well of the images of entry of exit. */
itkStaticConstMacro(InputImageDimension,
unsigned int,
TInputImage::ImageDimension);
itkStaticConstMacro(OutputImageDimension,
unsigned int,
TOutputImage::ImageDimension);
/** typedef for the classes standards. */
typedef DrawLineSpatialObjectFilter Self;
//typedef itk::ImageTo< itk::LineSpatialObject<2>, TOutputImage > Superclass;
typedef itk::ImageToImageFilter<TInputImage, TOutputImage> Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
/** Method for management of the "object factory". */
itkNewMacro(Self);
/** Return the name of the class. */
itkTypeMacro(DrawLineSpatialObjectFilter, /*SpatialObjectToImageFilter*/ itk::ImageToImageFilter);
/** typedef Support for input & output image*/
typedef TInputImage InputImageType;
typedef TOutputImage OutputImageType;
typedef typename OutputImageType::PixelType OutputPixelType;
/** Support typedef for input & Output*/
typedef itk::LineSpatialObject<2> InputLineType;
typedef itk::ProcessObject ProcessObjectType;
/** Typedef Support for lineList Type*/
typedef LineSpatialObjectList LineSpatialObjectListType;
typedef typename LineSpatialObjectListType::Pointer LineSpatialObjectListPointer;
/** Typedef Support for drawLineSpatialObjectListFilter*/
typedef otb::DrawLineSpatialObjectListFilter<InputImageType, OutputImageType> DrawLineSpatialObjectListFilterType;
typedef typename DrawLineSpatialObjectListFilterType::Pointer
DrawLineSpatialObjectListFilterPointerType;
/** Set/Get the image input of this process object. */
/* virtual void SetInputImage(const InputImageType *image); */
/* const InputImageType * GetInputImage(void); */
/** Get the input LineSpatialObjet (not const) */
virtual void SetInputLine(const InputLineType *line);
InputLineType * GetInputLine(void);
/** Set/Get pixel value */
itkSetMacro(Value, OutputPixelType);
itkGetConstReferenceMacro(Value, OutputPixelType);
protected:
DrawLineSpatialObjectFilter();
~DrawLineSpatialObjectFilter() override {}
void PrintSelf(std::ostream& os, itk::Indent indent) const override;
void GenerateData() override;
private:
DrawLineSpatialObjectFilter(const Self &) = delete;
void operator =(const Self&) = delete;
OutputPixelType m_Value;
DrawLineSpatialObjectListFilterPointerType m_DrawLineListFilter;
};
} // end namespace otb
#ifndef OTB_MANUAL_INSTANTIATION
#include "otbDrawLineSpatialObjectFilter.hxx"
#endif
#endif
/*
* Copyright (C) 2005-2019 Centre National d'Etudes Spatiales (CNES)
*
* This file is part of Orfeo Toolbox
*
* https://www.orfeo-toolbox.org/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef otbDrawLineSpatialObjectFilter_hxx
#define otbDrawLineSpatialObjectFilter_hxx
#include "otbDrawLineSpatialObjectFilter.h"
#include "itkDataObject.h"
#include "itkMacro.h"
#include "itkImageRegionIterator.h"
#include "itkImageIteratorWithIndex.h"
namespace otb
{
/**
*
*/
template <class TInputImage, class TOutputImage>
DrawLineSpatialObjectFilter<TInputImage, TOutputImage>::DrawLineSpatialObjectFilter()
{
this->SetNumberOfRequiredInputs(2);
this->SetNumberOfRequiredOutputs(1);
m_Value = static_cast<OutputPixelType>(255.0);
m_DrawLineListFilter = DrawLineSpatialObjectListFilterType::New();
}
template <class TInputImage, class TOutputImage>
void
DrawLineSpatialObjectFilter<TInputImage, TOutputImage>
::SetInputLine(const InputLineType *line)
{
this->ProcessObjectType::SetNthInput(1,
const_cast<InputLineType *>(line));
}
template <class TInputImage, class TOutputImage>
typename DrawLineSpatialObjectFilter<TInputImage, TOutputImage>::InputLineType *
DrawLineSpatialObjectFilter<TInputImage, TOutputImage>
::GetInputLine(void)
{
return static_cast<InputLineType *>
(this->ProcessObjectType::GetInput(1));
}
template <class TInputImage, class TOutputImage>
void
DrawLineSpatialObjectFilter<TInputImage, TOutputImage>
::GenerateData(void)
{
typename InputImageType::ConstPointer input = this->GetInput();
InputLineType * line = this->GetInputLine();
typename OutputImageType::Pointer output = this->GetOutput();
/** Create a new list line with one line*/
LineSpatialObjectListPointer lineList = LineSpatialObjectListType::New();
lineList->push_back(line);
/** Invoke the DrawLineSpatialObjectListFilter to draw the line */
m_DrawLineListFilter->SetInput(input);
m_DrawLineListFilter->SetInputLineSpatialObjectList(lineList);
m_DrawLineListFilter->GraftOutput(this->GetOutput());
m_DrawLineListFilter->Update();
this->GraftOutput(m_DrawLineListFilter->GetOutput());
}
/**
* Standard "PrintSelf" method
*/
template <class TInputImage, class TOutput>
void
DrawLineSpatialObjectFilter<TInputImage, TOutput>::PrintSelf(std::ostream& os, itk::Indent indent) const
{
Superclass::PrintSelf(os, indent);
os << indent << "Path Value: " << m_Value << std::endl;
}
} // end namespace otb
#endif
/*
* Copyright (C) 2005-2019 Centre National d'Etudes Spatiales (CNES)
*
* This file is part of Orfeo Toolbox
*
* https://www.orfeo-toolbox.org/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef otbDrawLineSpatialObjectListFilter_h
#define otbDrawLineSpatialObjectListFilter_h
#include "itkImageToImageFilter.h"
#include "otbLineSpatialObjectList.h"
namespace otb
{
/** \class DrawLineSpatialObjectListFilter
* \brief Composite filter which draw lines in an image.
*
* This class implements a composite filter that draws a list of lines in
* an input Image. This class
*
*
*
*
* \ingroup OTBSpatialObjects
*/
template <class TInputImage, class TOutputImage>
class ITK_EXPORT DrawLineSpatialObjectListFilter :
public itk::ImageToImageFilter<TInputImage, TOutputImage>
{
public:
/** Extract dimensions as well of the images of entry of exit. */
itkStaticConstMacro(InputImageDimension,
unsigned int,
TInputImage::ImageDimension);
itkStaticConstMacro(OutputImageDimension,
unsigned int,
TOutputImage::ImageDimension);
/** typedefs support for inputs & outputs*/
typedef TInputImage InputImageType;
typedef TOutputImage OutputImageType;
typedef typename OutputImageType::RegionType OutputImageRegionType;
/** typedef for the classes standards. */
typedef DrawLineSpatialObjectListFilter Self;
typedef itk::ImageToImageFilter<TInputImage, TOutputImage> Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
typedef LineSpatialObjectList LinesListType;
typedef LinesListType::LineType LineType;
typedef LineType::PointListType PointListType;
typedef typename LinesListType::const_iterator LineListIterator;
typedef itk::ProcessObject ProcessObjectType;
/** Method for management of the "object factory". */
itkNewMacro(Self);
/** Return the name of the class. */
itkTypeMacro(DrawLineSpatialObjectListFilter, ImageToImageFilter);
/** Definition of the input and output images */
typedef typename InputImageType::PixelType InputPixelType;
typedef typename OutputImageType::PixelType OutputPixelType;
typedef typename OutputImageType::IndexType OutputIndexType;
typedef typename OutputIndexType::IndexValueType OutputIndexValueType;
/** Set/Get the image input of this process object. */
virtual void SetInputLineSpatialObjectList(const LinesListType * list);
LinesListType * GetInputLineSpatialObjectList(void);
/** Get/Set m_Value*/
itkGetMacro(Value, OutputPixelType);
itkSetMacro(Value, OutputPixelType);
protected:
DrawLineSpatialObjectListFilter();
~DrawLineSpatialObjectListFilter() override {}
void PrintSelf(std::ostream& os, itk::Indent indent) const override;
void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) override;
/**
* compute the intersection of the segment to draw with the region
*/
virtual void CropSegment(OutputIndexType *indexToCrop,
OutputIndexType *otherIndex,
const OutputImageRegionType *outputRegionForThread) const;
virtual void CropRightSegment(OutputIndexType *indexToCrop,
OutputIndexType *otherIndex,
const OutputImageRegionType *outputRegionForThread) const;
virtual bool IsUpsideTheRegion(OutputIndexType *indexToCrop,
const OutputImageRegionType *outputRegionForThread) const;
virtual bool IsDownsideTheRegion(OutputIndexType *indexToCrop,
const OutputImageRegionType *outputRegionForThread) const;
virtual bool IsDownsideTheImage(OutputIndexType *indexToCrop) const;
virtual bool IsColumnOutsideOfTheRegion(OutputIndexType *indexToCheck,
OutputIndexType *otherToCheck,
const OutputImageRegionType *outputRegionForThread) const;
private:
DrawLineSpatialObjectListFilter(const Self &) = delete;
void operator =(const Self&) = delete;
OutputPixelType m_Value;
int m_Length;
int m_Width;
};
} // end namespace otb
#ifndef OTB_MANUAL_INSTANTIATION
#include "otbDrawLineSpatialObjectListFilter.hxx"
#endif
#endif
/*
* Copyright (C) 2005-2019 Centre National d'Etudes Spatiales (CNES)
*
* This file is part of Orfeo Toolbox
*
* https://www.orfeo-toolbox.org/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef otbImageToLineSpatialObjectListFilter_h
#define otbImageToLineSpatialObjectListFilter_h
#include "itkProcessObject.h"
#include "otbLineSpatialObjectList.h"
namespace otb
{
/** \class ImageToLineSpatialObjectListFilter
* \brief Base class for all process objects that output LineSpatialObjectList.
*
* ImageToLineSpatialObjectListFilter is the base class for all process objects
* that output list of LineSpatialObject.
*
*
* \ingroup OTBSpatialObjects
*/
template <class TInputImage>
class ITK_EXPORT ImageToLineSpatialObjectListFilter : public itk::ProcessObject
{
public:
/** Extract dimensions as well of the images of entry of exit. */
itkStaticConstMacro(InputImageDimension,
unsigned int,
TInputImage::ImageDimension);
typedef TInputImage InputImageType;
/** Standard class typedefs. */
typedef ImageToLineSpatialObjectListFilter Self;
typedef itk::ProcessObject Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
/** Method for creation through the object factory. */
itkNewMacro(Self);
/** Run-time type information (and related methods). */
itkTypeMacro(ImageToLineSpatialObjectListFilter, itk::ProcessObject);
/** Some convenient typedefs. */
typedef LineSpatialObjectList LinesListType;
typedef typename LinesListType::LineType LineType;
/** Definition of the input and output images */
typedef typename InputImageType::PixelType InputPixelType;
/** Definition of the size of the images. */
typedef typename InputImageType::SizeType SizeType;
typedef itk::ProcessObject ProcessObjectType;
/** Set/Get the input image */
using Superclass::SetInput;
void SetInput(const InputImageType *image);
const InputImageType * GetInput(void);
/** Set/Get the list of LineSpatialObject of this process object. */
using Superclass::SetOutput;
void SetOutput(const LinesListType *list);
LinesListType * GetOutput(void);
protected:
ImageToLineSpatialObjectListFilter();
~ImageToLineSpatialObjectListFilter() override {}
void PrintSelf(std::ostream& os, itk::Indent indent) const override;
private:
ImageToLineSpatialObjectListFilter(const Self &) = delete;
void operator =(const Self&) = delete;
};
} // end namespace otb
#ifndef OTB_MANUAL_INSTANTIATION
#include "otbImageToLineSpatialObjectListFilter.hxx"
#endif
#endif
/*
* Copyright (C) 2005-2019 Centre National d'Etudes Spatiales (CNES)
*
* This file is part of Orfeo Toolbox
*
* https://www.orfeo-toolbox.org/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef otbImageToLineSpatialObjectListFilter_hxx
#define otbImageToLineSpatialObjectListFilter_hxx
#include "otbImageToLineSpatialObjectListFilter.h"
namespace otb
{
/**
*
*/
template<class TInputImage>
ImageToLineSpatialObjectListFilter<TInputImage>::ImageToLineSpatialObjectListFilter()
{
this->SetNumberOfRequiredInputs(1);
this->SetNumberOfRequiredOutputs(1);
typename LinesListType::Pointer list = LinesListType::New();
this->SetOutput(list);
}
template <class TInputImage>
void
ImageToLineSpatialObjectListFilter<TInputImage>
::SetInput(const InputImageType *image)
{
this->itk::ProcessObject::SetNthInput(0,
const_cast<InputImageType *>(image));
}
template <class TInputImage>
const typename ImageToLineSpatialObjectListFilter<TInputImage>::InputImageType *
ImageToLineSpatialObjectListFilter<TInputImage>
::GetInput(void)
{
return static_cast<const InputImageType *>
(this->itk::ProcessObject::GetInput(0));
}
template <class TInputImage>
void
ImageToLineSpatialObjectListFilter<TInputImage>
::SetOutput(const LinesListType *list)
{
this->ProcessObjectType::SetNthOutput(0,
const_cast<LinesListType *>(list));
}
template <class TInputImage>
typename ImageToLineSpatialObjectListFilter<TInputImage>::LinesListType *
ImageToLineSpatialObjectListFilter<TInputImage>
::GetOutput(void)
{
return static_cast<LinesListType *>
(this->ProcessObjectType::GetOutput(0));
}
/**
*
*/
template<class TInputImage>
void
ImageToLineSpatialObjectListFilter<TInputImage>
::PrintSelf(std::ostream& os, itk::Indent indent) const
{
Superclass::PrintSelf(os, indent);
}
} // end namespace otb
#endif
/*
* Copyright (C) 2005-2019 Centre National d'Etudes Spatiales (CNES)
*
* This file is part of Orfeo Toolbox
*
* https://www.orfeo-toolbox.org/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef otbLineSpatialObject_h
#define otbLineSpatialObject_h
#include "itkPointBasedSpatialObject.h"
#include "itkLineSpatialObjectPoint.h"
namespace otb
{
/** \class LineSpatialObject
* \brief Representation of a Line based on the spatial object classes.
*
* The Line is basically defined by a set of points.
*
* \sa LineSpatialObjectPoint
*
* \ingroup OTBSpatialObjects
*/
template <unsigned int VDimension = 3>
class ITK_EXPORT LineSpatialObject
: public itk::PointBasedSpatialObject<VDimension>
{
public:
/** Standard typedefs */
typedef LineSpatialObject Self;
typedef itk::PointBasedSpatialObject<VDimension> Superclass;
typedef itk::SmartPointer<Self> Pointer;