/*============================================================================

The Medical Imaging Interaction Toolkit (MITK)

Copyright (c) German Cancer Research Center (DKFZ)
All rights reserved.

Use of this source code is governed by a 3-clause BSD license that can be
found in the LICENSE file.

============================================================================*/

#ifndef mitkEllipsoid_h
#define mitkEllipsoid_h

#include <MitkDataTypesExtExports.h>
#include <mitkBoundingObject.h>

namespace mitk
{
  /**
   * \brief Bounding object shaped as an ellipsoid.
   *
   * The ellipsoid has unit radius in all axes in object coordinates and is
   * centered at the origin. Its surface is generated by vtkSphereSource.
   * Volume is calculated as (4/3) * pi * rx * ry * rz from the geometry extents.
   *
   * \sa BoundingObject, Cone, Cuboid, Cylinder
   * \ingroup Data
   */
  class MITKDATATYPESEXT_EXPORT Ellipsoid : public BoundingObject
  {
  public:
    mitkClassMacro(Ellipsoid, BoundingObject);
    itkFactorylessNewMacro(Self);
    itkCloneMacro(Self);

    /**
     * \brief Calculate the ellipsoid volume from the geometry extents.
     * \return The volume in world-coordinate units cubed.
     */
    mitk::ScalarType GetVolume() override;

    /**
     * \brief Test whether a world-coordinate point lies inside the ellipsoid.
     *
     * The point is transformed to object coordinates and checked against
     * the unit sphere equation x^2 + y^2 + z^2 <= 1.
     *
     * \param[in] p The point in world coordinates.
     * \return true if the point is inside.
     */
    bool IsInside(const Point3D &p) const override;

  protected:
    Ellipsoid();
    ~Ellipsoid() override;
  };
}
#endif
