Program Listing for File triangleground.hxx

Return to documentation for file (src/enve/triangleground.hxx)

/*
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *                                                                     *
 * The ENVE project                                                    *
 *                                                                     *
 * Copyright (c) 2020, Davide Stocco and Enrico Bertolazzi.            *
 *                                                                     *
 * The ENVE project and its components are supplied under the terms of *
 * the open source BSD 3-Clause License. The contents of the ENVE      *
 * project and its components may not be copied or disclosed except in *
 * accordance with the terms of the BSD 3-Clause License.              *
 *                                                                     *
 * URL: https://opensource.org/licenses/BSD-3-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                               *
 *                                                                     *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/


#ifndef INCLUDE_ENVE_TRIANGLEGROUND_HXX
#define INCLUDE_ENVE_TRIANGLEGROUND_HXX

namespace enve
{

  /*\
   |   _        _                   _                          _
   |  | |_ _ __(_) __ _ _ __   __ _| | ___ _ __ ___   __ _  __| |
   |  | __| '__| |/ _` | '_ \ / _` | |/ _ \ '__/ _ \ / _` |/ _` |
   |  | |_| |  | | (_| | | | | (_| | |  __/ | | (_) | (_| | (_| |
   |   \__|_|  |_|\__,_|_| |_|\__, |_|\___|_|  \___/ \__,_|\__,_|
   |                          |___/
  \*/

  class triangleground : public triangle
  {
  public:
    typedef std::shared_ptr<triangleground const> ptr;
    typedef std::vector<triangleground::ptr>      vecptr;

  private:
    integer m_id;
    real    m_friction;
    vec3    m_normal;
    aabb    m_bbox;

  public:
    triangleground(triangleground const &) = delete;

    triangleground(triangleground &&) = delete;

    triangleground & operator=(const triangleground &) = delete;

    triangleground & operator=(triangleground &&) = delete;

    ~triangleground(void) override = default;

    triangleground(void);

    triangleground(
      integer id,
      real    friction,
      real    vertex_0_x,
      real    vertex_0_y,
      real    vertex_0_z,
      real    vertex_1_x,
      real    vertex_1_y,
      real    vertex_1_z,
      real    vertex_2_x,
      real    vertex_2_y,
      real    vertex_2_z
    );

    triangleground(
      integer         id,
      real            friction,
      point   const & point_0,
      point   const & point_1,
      point   const & point_2
    );

    triangleground(
      integer       id,
      real          friction,
      point   const vertex[3]
    );

    void
    copy(
      triangleground const & triangleground_obj
    );

    bool
    isApprox(
      triangleground const & triangleground_obj,
      real                   tolerance = EPSILON_LOW
    ) const;

    integer const &
    id(void)
    const;

    real const &
    friction(void)
    const;

    aabb const &
    bbox(void)
    const;

    vec3 const &
    normal(void)
    const;

    point const &
    operator[](
      size_t i
    ) const;

    point const &
    vertex(
      size_t i
    ) const;

    void
    print(
      out_stream & os
    ) const;

  private:
    void
    updateNormal(void);

    void
    updateBBox(void);

    point &
    operator[](
      size_t i
    );

    point &
    vertex(
      size_t i
    );

  }; // class triangleground

} // namespace enve

#endif