diff --git a/Code/Common/otbArcSpatialObject.h b/Code/Common/otbArcSpatialObject.h deleted file mode 100644 index 357fbe87de3166adb791118ffd5dd8aa97227be9..0000000000000000000000000000000000000000 --- a/Code/Common/otbArcSpatialObject.h +++ /dev/null @@ -1,130 +0,0 @@ -/*========================================================================= - - Program: ORFEO Toolbox - Language: C++ - Date: $Date$ - Version: $Revision$ - - - Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. - See OTBCopyright.txt for details. - - - 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 __otbArcSpatialObject_h -#define __otbArcSpatialObject_h - -#include "itkSpatialObject.h" -#include "itkAffineTransform.h" -#include "itkFixedArray.h" - -namespace otb -{ -/** \class ArcSpatialObject - * \brief TODO - * - */ -template <unsigned int VDimension = 2> -class ITK_EXPORT ArcSpatialObject - : public itk::SpatialObject<VDimension> -{ -public: - /** Standard typedefs */ - typedef ArcSpatialObject Self; - typedef itk::SpatialObject<VDimension> Superclass; - typedef itk::SmartPointer<Self> Pointer; - typedef itk::SmartPointer<const Self> ConstPointer; - - /** Type macro */ - itkNewMacro(Self); - - /** Creation through object factory macro */ - itkTypeMacro(ArcSpatialObject, SpatialObject); - - /** Get the number of Dimensions */ - itkStaticConstMacro(NumberOfDimension, unsigned int, VDimension); - - /** Superclass typedefs */ - typedef typename Superclass::PointType PointType; - typedef typename Superclass::TransformType TransformType; - typedef typename Superclass::BoundingBoxType BoundingBoxType; - - /** Additional typedefs */ - typedef itk::VectorContainer<unsigned long, PointType> PointContainerType; - typedef itk::SmartPointer<PointContainerType> PointContainerPointer; - /** - * Set all radii to the same radius value. Each radius is - * half the length of one axis of the ellipse. - */ - itkSetMacro(Radius, double); - itkGetConstReferenceMacro(Radius, double); - /// Set the Start Angle - itkSetMacro(Angle1, double); - itkGetMacro(Angle1, double); - - //Set the End Angle - itkSetMacro(Angle2, double); - itkGetMacro(Angle2, double); - /** - * That's useful for fuzzy objects. - * \return a degree of membership to the object. - */ - virtual bool ValueAt(const PointType& point, double& value, - unsigned int depth = 0, - char * name = NULL) const; - /** - * \return true if the object provides a method to evaluate the value - * at the specified point, false otherwise. - */ - virtual bool IsEvaluableAt(const PointType& point, - unsigned int depth = 0, - char * name = NULL) const; - /** - * Test whether a point is inside or outside the object - */ - virtual bool IsInside(const PointType& point, - unsigned int depth, - char *) const; - /** - * Test whether a point is inside or outside the object - * For computational speed purposes, it is faster if the method does not - * check the name of the class and the current depth - */ - virtual bool IsInside(const PointType& point) const; - /** - * Get the boundaries of a specific object. This function needs to - * be called every time one of the object's components is - * changed. - */ - virtual bool ComputeLocalBoundingBox() const; - /** - * Copy the information from another SpatialObject - */ - void CopyInformation(const itk::DataObject *data); - -protected: - /** Constructor */ - ArcSpatialObject(); - /** Destructor */ - virtual ~ArcSpatialObject() {} - /**PrintSelf method */ - virtual void PrintSelf(std::ostream& os, itk::Indent indent) const; - -private: - ArcSpatialObject(const Self &); //purposely not implemented - void operator =(const Self&); //purposely not implemented - - double m_Radius; - double m_Angle1; - double m_Angle2; -}; -} // End namespace otb -#ifndef OTB_MANUAL_INSTANTIATION -#include "otbArcSpatialObject.txx" -#endif - -#endif diff --git a/Code/Common/otbArcSpatialObject.txx b/Code/Common/otbArcSpatialObject.txx deleted file mode 100644 index 9cd825b426c3ed62e8ced5086c6af9883a0a5bfa..0000000000000000000000000000000000000000 --- a/Code/Common/otbArcSpatialObject.txx +++ /dev/null @@ -1,297 +0,0 @@ -/*========================================================================= - - Program: ORFEO Toolbox - Language: C++ - Date: $Date$ - Version: $Revision$ - - - Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. - See OTBCopyright.txt for details. - - - 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 __otbArcSpatialObject_txx -#define __otbArcSpatialObject_txx - -#include "otbArcSpatialObject.h" -#include "otbMath.h" - -namespace otb -{ -/** - * Constructor. - */ -template<unsigned int VDimension> -ArcSpatialObject<VDimension> -::ArcSpatialObject() -{ - this->SetTypeName("ArcSpatialObject"); - m_Radius = 1.0; - this->SetDimension(VDimension); - m_Angle1 = 0.0; - m_Angle2 = 0.0; -} -/** - * Test whether a point is inside or outside the object - * For computational speed purposes, it is faster if the method does not - * check the name of the class and the current depth - */ -template<unsigned int VDimension> -bool -ArcSpatialObject<VDimension> -::IsInside(const PointType& point) const -{ - this->ComputeLocalBoundingBox(); - if (!this->GetIndexToWorldTransform()->GetInverse(const_cast<TransformType *>(this->GetInternalInverseTransform()))) - { - return false; - } - - PointType transformedPoint = this->GetInternalInverseTransform()->TransformPoint(point); - double r = 0; - for (unsigned int i = 0; i < VDimension; ++i) - { - if (m_Radius != 0.0) - { - r += ((transformedPoint[i] * transformedPoint[i]) / (m_Radius * m_Radius)); - } - else if (transformedPoint[i] > 0.0) // Degenerate ellipse - { - r = 2; // Keeps function from returning true here - break; - } - } - if (r <= 1) - { - double angle(0.); - if (transformedPoint[0] != 0) - { - angle = vcl_atan(transformedPoint[1] / transformedPoint[0]) * 180 / CONST_PI; - } - else if (transformedPoint[1] > 0) - { - angle = 90; - } - else if (transformedPoint[1] < 0) - { - angle = -90; - } -// std::cout << "\n angle= " << angle << std::endl; - if (angle >= m_Angle1 && angle <= m_Angle2) - { -// std::cout << "----> OK") << std::endl; - return true; - } - else return false; - - } - return false; -} -/** - * Test if the given point is inside the arc - */ -template<unsigned int VDimension> -bool -ArcSpatialObject<VDimension> -::IsInside(const PointType& point, unsigned int depth, char * name) const -{ -// itkDebugMacro( "Checking the point [" << point << "] is inside the Arc" ); - - if (name == NULL) - { - if (IsInside(point)) - { - return true; - } - } - else if (strstr(typeid(Self).name(), name)) - { - if (IsInside(point)) - { - return true; - } - } - return Superclass::IsInside(point, depth, name); -} -/** - * Compute the bounds of the arc - */ -template<unsigned int VDimension> -bool -ArcSpatialObject<VDimension> -::ComputeLocalBoundingBox() const -{ - itkDebugMacro("Computing arc bounding box"); - if (this->GetBoundingBoxChildrenName().empty() - || strstr(typeid(Self).name(), this->GetBoundingBoxChildrenName().c_str())) - { - // we need to set the minimum and maximum of the bounding box - // the center is always inside the bounding box. - PointType center; - center.Fill(0); - center = this->GetIndexToWorldTransform()->TransformPoint(center); - const_cast<BoundingBoxType *>(this->GetBounds())->SetMinimum(center); - const_cast<BoundingBoxType *>(this->GetBounds())->SetMaximum(center); - - // First we compute the bounding box in the index space - typename BoundingBoxType::Pointer bb = BoundingBoxType::New(); - - PointType pntA; - PointType pntB; - PointType pntC; - PointType pntD; - - double alpha, longueur, largeur; - alpha = (m_Angle2 - m_Angle1); // Difference between 2 angles. - - if (alpha <= 180) - { - pntA[0] = m_Radius * vcl_cos(m_Angle1 * CONST_PI / 180); - pntA[1] = m_Radius * vcl_sin(m_Angle1 * CONST_PI / 180); - pntB[0] = m_Radius * vcl_cos(m_Angle2 * CONST_PI / 180); - pntB[1] = m_Radius * vcl_sin(m_Angle2 * CONST_PI / 180); - - longueur = vcl_sqrt((pntB[0] - pntA[0]) * (pntB[0] - pntA[0]) + (pntB[1] - pntA[1]) * (pntB[1] - pntA[1])); - largeur = m_Radius * (1 - vcl_cos((alpha / 2) * CONST_PI / 180)); - pntC[0] = pntB[0] + largeur * (pntB[1] - pntA[1]) / longueur; - pntC[1] = pntB[1] - largeur * (pntB[0] - pntA[0]) / longueur; - pntD[0] = pntA[0] + largeur * (pntB[1] - pntA[1]) / longueur; - pntD[1] = pntA[1] - largeur * (pntB[0] - pntA[0]) / longueur; - } - else - { - pntA[0] = m_Radius * vcl_cos(m_Angle1 * CONST_PI / 180); - pntA[1] = m_Radius * vcl_sin(m_Angle1 * CONST_PI / 180); - pntB[0] = m_Radius * vcl_cos(m_Angle2 * CONST_PI / 180); - pntB[1] = m_Radius * vcl_sin(m_Angle2 * CONST_PI / 180); - longueur = vcl_sqrt((pntB[0] - pntA[0]) * (pntB[0] - pntA[0]) + (pntB[1] - pntA[1]) * (pntB[1] - pntA[1])); - largeur = m_Radius * (1 - vcl_cos((alpha / 2) * CONST_PI / 180)); - pntA[0] = - (m_Radius / - 2) * - (vcl_cos(m_Angle1 * CONST_PI / - 180) + - vcl_cos(m_Angle2 * CONST_PI / - 180)) - (m_Radius * m_Radius / longueur) * (vcl_cos(m_Angle1 * CONST_PI / 180) - vcl_cos(m_Angle2 * CONST_PI / 180)); - pntA[1] = - (m_Radius / - 2) * - (vcl_sin(m_Angle1 * CONST_PI / - 180) + - vcl_sin(m_Angle2 * CONST_PI / - 180)) - (m_Radius * m_Radius / longueur) * (vcl_sin(m_Angle1 * CONST_PI / 180) - vcl_sin(m_Angle2 * CONST_PI / 180)); - pntB[0] = - (m_Radius / - 2) * - (vcl_cos(m_Angle1 * CONST_PI / - 180) + - vcl_cos(m_Angle2 * CONST_PI / - 180)) + (m_Radius * m_Radius / longueur) * (vcl_cos(m_Angle1 * CONST_PI / 180) - vcl_cos(m_Angle2 * CONST_PI / 180)); - pntB[1] = - (m_Radius / - 2) * - (vcl_sin(m_Angle1 * CONST_PI / - 180) + - vcl_sin(m_Angle2 * CONST_PI / - 180)) + (m_Radius * m_Radius / longueur) * (vcl_sin(m_Angle1 * CONST_PI / 180) - vcl_sin(m_Angle2 * CONST_PI / 180)); - pntC[0] = pntB[0] - (largeur / (2 * m_Radius)) * (pntB[1] - pntA[1]); - pntC[1] = pntB[1] + (largeur / (2 * m_Radius)) * (pntB[0] - pntA[0]); - pntD[0] = pntA[0] - (largeur / (2 * m_Radius)) * (pntB[1] - pntA[1]); - pntD[1] = pntA[1] + (largeur / (2 * m_Radius)) * (pntB[0] - pntA[0]); - } - bb->ConsiderPoint(pntA); - bb->ConsiderPoint(pntB); - bb->ConsiderPoint(pntC); - bb->ConsiderPoint(pntD); - bb->ComputeBoundingBox(); - PointType pnt = this->GetIndexToWorldTransform()->TransformPoint(pntA); - const_cast<BoundingBoxType *>(this->GetBounds())->ConsiderPoint(pnt); - pnt = this->GetIndexToWorldTransform()->TransformPoint(pntB); - const_cast<BoundingBoxType *>(this->GetBounds())->ConsiderPoint(pnt); - pnt = this->GetIndexToWorldTransform()->TransformPoint(pntC); - const_cast<BoundingBoxType *>(this->GetBounds())->ConsiderPoint(pnt); - pnt = this->GetIndexToWorldTransform()->TransformPoint(pntD); - const_cast<BoundingBoxType *>(this->GetBounds())->ConsiderPoint(pnt); - } - return true; -} -/** - * Returns if the arc is evaluable at one point - */ -template<unsigned int VDimension> -bool -ArcSpatialObject<VDimension> -::IsEvaluableAt(const PointType& point, unsigned int depth, char * name) const -{ - // itkDebugMacro( "Checking if the arc is evaluable at " << point ); - return IsInside(point, depth, name); -} -/** - * Returns the value at one point - */ -template<unsigned int VDimension> -bool -ArcSpatialObject<VDimension> -::ValueAt(const PointType& point, double& value, unsigned int depth, - char * name) const -{ - // itkDebugMacro( "Getting the value of the arc at " << point ); - if (IsInside(point, 0, name)) - { - value = this->GetDefaultInsideValue(); - return true; - } - else - { - if (Superclass::IsEvaluableAt(point, depth, name)) - { - Superclass::ValueAt(point, value, depth, name); - return true; - } - else - { - value = this->GetDefaultOutsideValue(); - return false; - } - } - return false; -} -/** - * Print Self function - */ -template<unsigned int VDimension> -void -ArcSpatialObject<VDimension> -::PrintSelf(std::ostream& os, itk::Indent indent) const -{ - Superclass::PrintSelf(os, indent); - os << "Radius: " << m_Radius << std::endl; -} -/** - * Copy the information from another spatial object - */ -template<unsigned int VDimension> -void ArcSpatialObject<VDimension> -::CopyInformation(const itk::DataObject *data) -{ - // check if we are the same type - const Self* source = dynamic_cast<const Self*>(data); - if (!source) - { - std::cout << "CopyInformation: objects are not of the same type" << std::endl; - return; - } - // copy the properties - Superclass::CopyInformation(data); - - // copy the internal info - this->SetRadius(source->GetRadius()); -} -} // end namespace otb - -#endif diff --git a/Code/IO/otbDXFToSpatialObjectGroupFilter.h b/Code/IO/otbDXFToSpatialObjectGroupFilter.h index f21ea3441b81ede582c33c42cdfc0243bbaf2560..a8292006054747a01511adf27624520e73c7b654 100644 --- a/Code/IO/otbDXFToSpatialObjectGroupFilter.h +++ b/Code/IO/otbDXFToSpatialObjectGroupFilter.h @@ -28,7 +28,6 @@ #include "itkLandmarkSpatialObject.h" #include "otbLineSpatialObject.h" #include "itkLineSpatialObjectPoint.h" -#include "otbArcSpatialObject.h" namespace otb { @@ -64,8 +63,6 @@ public: typedef typename LineType::Pointer LinePointer; typedef itk::LineSpatialObjectPoint<TSpatialObject::ObjectDimension> LinePointType; typedef typename LineType::PointListType LineListType; - typedef otb::ArcSpatialObject<TSpatialObject::ObjectDimension> ArcType; - typedef typename ArcType::Pointer ArcPointer; typedef itk::EllipseSpatialObject<TSpatialObject::ObjectDimension> EllipseType; typedef typename EllipseType::Pointer EllipsePointer; typedef std::vector<LinePointType> PointListType; diff --git a/Testing/Code/Common/CMakeLists.txt b/Testing/Code/Common/CMakeLists.txt index 4ee819a06883327d0ad0142c168c955aeb3f3f3e..026d1cfcf275c01b818fcc7a8b6cf485d8e9001e 100644 --- a/Testing/Code/Common/CMakeLists.txt +++ b/Testing/Code/Common/CMakeLists.txt @@ -473,10 +473,6 @@ ADD_TEST(coTuSpatialObjectSourceNew ${COMMON_TESTS5} ADD_TEST(coTuLineSpatialObjectNew ${COMMON_TESTS5} otbLineSpatialObjectNew) -# ------- otb::ArcSpatialObject ------------------------------------------- -ADD_TEST(coTuArcSpatialObjectNew ${COMMON_TESTS5} - otbArcSpatialObjectNew) - # ------- otb::PathListToPathListFilter ------------------------------------------- ADD_TEST(coTuPathListToPathListFilterNew ${COMMON_TESTS5} otbPathListToPathListFilterNew) @@ -1003,7 +999,6 @@ otbImageToVectorImageCastFilter.cxx otbImageToPathFilterNew.cxx otbSpatialObjectSourceNew.cxx otbLineSpatialObjectNew.cxx -otbArcSpatialObjectTest.cxx otbPathListToPathListFilterNew.cxx ) SET(BasicCommon_SRCS6 diff --git a/Testing/Code/Common/otbArcSpatialObjectTest.cxx b/Testing/Code/Common/otbArcSpatialObjectTest.cxx deleted file mode 100644 index ccc66568e91d37308fb9e2e55ee2e258d65d6f8c..0000000000000000000000000000000000000000 --- a/Testing/Code/Common/otbArcSpatialObjectTest.cxx +++ /dev/null @@ -1,31 +0,0 @@ -/*========================================================================= - - Program: ORFEO Toolbox - Language: C++ - Date: $Date$ - Version: $Revision$ - - - Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. - See OTBCopyright.txt for details. - - - 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. - -=========================================================================*/ -#include "itkExceptionObject.h" - -#include "otbArcSpatialObject.h" - -int otbArcSpatialObjectNew(int argc, char * argv[]) -{ - const unsigned int Dimension = 2; - typedef otb::ArcSpatialObject<Dimension> ArcSpatialObjectType; - - // Instantiating object - ArcSpatialObjectType::Pointer object = ArcSpatialObjectType::New(); - - return EXIT_SUCCESS; -} diff --git a/Testing/Code/Common/otbCommonTests5.cxx b/Testing/Code/Common/otbCommonTests5.cxx index ef0ef6287c7ab6c7f9f31de77f70a95d51ce1aae..158307f131c4ee094577e29c1470b331860f222a 100644 --- a/Testing/Code/Common/otbCommonTests5.cxx +++ b/Testing/Code/Common/otbCommonTests5.cxx @@ -34,6 +34,5 @@ void RegisterTests() REGISTER_TEST(otbImageToPathFilterNew); REGISTER_TEST(otbSpatialObjectSourceNew); REGISTER_TEST(otbLineSpatialObjectNew); - REGISTER_TEST(otbArcSpatialObjectNew); REGISTER_TEST(otbPathListToPathListFilterNew); }