Program Listing for File disk.hxx¶
↰ Return to documentation for file (src/acme/disk.hxx)
/*
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *                                                                     *
 * The ACME project                                                    *
 *                                                                     *
 * Copyright (c) 2020, Davide Stocco and Enrico Bertolazzi.            *
 *                                                                     *
 * The ACME project and its components are supplied under the terms of *
 * the open source BSD 2-Clause License. The contents of the ACME      *
 * project and its components may not be copied or disclosed except in *
 * accordance with the terms of the BSD 2-Clause License.              *
 *                                                                     *
 * URL: https://opensource.org/licenses/BSD-2-Clause                   *
 *                                                                     *
 *    Davide Stocco                                                    *
 *    Department of Industrial Engineering                             *
 *    University of Trento                                             *
 *    e-mail: davide.stocco@unitn.it                                   *
 *                                                                     *
 *    Enrico Bertolazzi                                                *
 *    Department of Industrial Engineering                             *
 *    University of Trento                                             *
 *    e-mail: enrico.bertolazzi@unitn.it                               *
 *                                                                     *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/
#pragma once
#ifndef INCLUDE_ACME_DISK_HXX
#define INCLUDE_ACME_DISK_HXX
#include "point.hxx"
#include "plane.hxx"
#include "aabb.hxx"
namespace acme
{
  /*\
   |       _ _     _
   |    __| (_)___| | __
   |   / _` | / __| |/ /
   |  | (_| | \__ \   <
   |   \__,_|_|___/_|\_\
   |
  \*/
  class disk : public entity
  {
  private:
    real  m_radius = QUIET_NAN;
    plane m_plane  = NAN_PLANE;
  public:
    disk(disk const &) = default;
    disk(disk &&) = default;
    disk & operator=(const disk &) = default;
    disk & operator=(disk &&) = default;
    ~disk(void) override = default;
    disk(void);
    disk(
      real          radius,
      plane const & plane
    );
    disk(
      real          radius,
      point const & center,
      vec3  const & normal
    );
    disk(
      real radius,
      real center_x,
      real center_y,
      real center_z,
      real normal_x,
      real normal_y,
      real normal_z
    );
    bool
    isApprox(
      disk const & disk_in,
      real         tolerance = EPSILON
    ) const;
    real const &
    radius(void)
    const;
    real &
    radius(void);
    point const &
    center(void)
    const;
    point &
    center(void);
    vec3 const &
    normal(void)
    const;
    vec3 &
    normal(void);
    plane const &
    layingPlane(void)
    const;
    plane &
    layingPlane(void);
    void
    normalize(void);
    void
    reverse(void);
    real
    perimeter(void)
    const;
    real
    area(void)
    const;
    void
    translate(
      vec3 const & vector_in
    ) override;
    void
    transform(
      affine const & affine_in
    ) override;
    bool
    isInside(
      point const & point_in,
      real          tolerance = EPSILON
    ) const;
    bool
    isDegenerated(
      real tolerance = EPSILON
    ) const override;
    inline
    integer
    level(void)
      const override
    {
      return integer(8);
    }
    inline
    std::string
    type(void)
      const override
    {
      return "disk";
    }
    inline
    bool
    isNone(void)
      const override
    {
      return false;
    }
    inline
    bool
    isPoint(void)
      const override
    {
      return false;
    }
    inline
    bool
    isLine(void)
      const override
    {
      return false;
    }
    inline
    bool
    isRay(void)
      const override
    {
      return false;
    }
    inline
    bool
    isPlane(void)
      const override
    {
      return false;
    }
    inline
    bool
    isSegment(void)
      const override
    {
      return false;
    }
    inline
    bool
    isTriangle(void)
      const override
    {
      return false;
    }
    inline
    bool
    isDisk(void)
      const override
    {
      return true;
    }
    inline
    bool
    isBall(void)
      const override
    {
      return false;
    }
    inline
    bool
    isClampable(void)
      const override
    {
      return true;
    }
    inline
    bool
    isNonClampable(void)
      const override
    {
      return false;
    }
    bool
    clamp(
      vec3 & min,
      vec3 & max
    ) const override;
    bool
    clamp(
      real & min_x,
      real & min_y,
      real & min_z,
      real & max_x,
      real & max_y,
      real & max_z
    ) const override;
  }; // class disk
  static disk const & NAN_DISK   = * new disk(QUIET_NAN, NAN_PLANE);
  static disk       & DUMMY_DISK = * new disk(QUIET_NAN, NAN_PLANE);
} // namespace acme
#endif