Program Listing for File shell.hxx

Return to documentation for file (src/enve/shell.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_SHELL_HXX
#define INCLUDE_ENVE_SHELL_HXX

#include "flat.hxx"
#include "mesh.hxx"
#include "rib.hxx"
#include "shape.hxx"
#include "output.hxx"

namespace enve
{

  /*\
   |       _          _ _
   |   ___| |__   ___| | |
   |  / __| '_ \ / _ \ | |
   |  \__ \ | | |  __/ | |
   |  |___/_| |_|\___|_|_|
   |
  \*/

  class shell
  {
  private:
    affine                              m_affine;
    std::shared_ptr<shape>              m_shape;
    std::shared_ptr<aabb>               m_bbox;
    std::vector<rib>                    m_ribs;
    std::vector<output>                 m_out;
    std::vector<triangleground::vecptr> m_candidates;

  public:
    shell(shell const &) = delete;

    shell(shell &&) = delete;

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

    shell & operator=(shell &&) = delete;

    ~shell(void) = default;

    shell(
      size_t size,
      real   r_x,
      real   m_x,
      real   r_y,
      real   m_y,
      real   l_y
    );

    shell(
      size_t         size,
      shape  const & shape_obj
    );

    void
    resize(
      size_t size
    );

    size_t
    size(void) const;

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

    real
    surfaceMaxRadius(void)
    const;

    real
    surfaceMaxWidth(void)
    const;

    real
    surfaceWidth(void)
    const;

    bool
    checkWidthBound(
      real y
    ) const;

    real
    surfaceRadius(
      real y
    ) const;

    real
    surfaceDerivative(
      real y,
      real tolerance = EPSILON_MEDIUM
    ) const;

    real
    surfaceAngle(
      real y,
      real tolerance = EPSILON_MEDIUM
    ) const;

    real
    ribRadius(
      size_t i
    ) const;

    point
    ribCenter(
      size_t i
    ) const;

    real
    ribWidth(
      size_t i
    ) const;

    real
    ribAngle(
      size_t i
    ) const;

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

    void
    translate(
      vec3 const & vector
    );

    vec3
    translation(void)
    const;

    void
    rotate(
      real         angle,
      vec3 const & axis
    );

    void
    rotate(
      real                angle,
      std::string const & axis
    );

    mat3
    rotation(void)
    const;

    mat3
    linear(void)
    const;

    void
    transform(
      affine const & pose
    );

    void
    transform(
      mat4 const & pose
    );

    affine const &
    transformation(void)
    const;

    bool
    checkTransformation(
      mat4 const & pose,
      real         tolerance = EPSILON_LOW
    ) const;

    bool
    checkTransformation(
      affine const & pose,
      real           tolerance = EPSILON_LOW
    ) const;

    vec3
    x(void)
    const;

    vec3
    y(void)
    const;

    vec3
    z(void)
    const;

    void
    eulerAngles(
      vec3 & angles
    ) const;

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

    std::shared_ptr<aabb>
    bbox(void) const;

    void
    updateBBox(void);

    /*\
     |            _
     |   ___  ___| |_ _   _ _ __
     |  / __|/ _ \ __| | | | '_ \
     |  \__ \  __/ |_| |_| | |_) |
     |  |___/\___|\__|\__,_| .__/
     |                     |_|
    \*/

    bool
    setup(
      ground::mesh const & ground,
      affine       const & pose,
      std::string  const   method
    );

    bool
    setup(
      ground::flat const & ground,
      affine       const & pose,
      std::string  const   method
    );

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

    void
    contactPoint(
      point & point
    ) const;

    void
    contactPoint(
      size_t   i,
      point  & point
    ) const;

    void
    contactPoint(
      std::vector<point> & point
    ) const;

    void
    contactNormal(
      vec3 & normal
    ) const;

    void
    contactNormal(
      size_t   i,
      vec3   & normal
    ) const;

    void
    contactNormal(
      std::vector<vec3> & normal
    ) const;

    void
    contactFriction(
      real & friction
    ) const;

    void
    contactFriction(
      size_t   i,
      real   & friction
    ) const;

    void
    contactFriction(
      std::vector<real> & friction
    ) const;

    void
    contactDepth(
      real & depth
    ) const;

    void
    contactDepth(
      size_t   i,
      real   & depth
    ) const;

    void
    contactDepth(
      std::vector<real> & depth
    ) const;

    void
    contactArea(
      real & area
    ) const;

    void
    contactArea(
      size_t   i,
      real   & area
    ) const;

    void
    contactArea(
      std::vector<real> & area
    ) const;

    void
    contactVolume(
      real & volume
    ) const;

    void
    contactVolume(
      size_t   i,
      real   & volume
    ) const;

    void
    contactVolume(
      std::vector<real> & volume
    ) const;

    void
    contactPointAffine(
      affine & pose
    ) const;

    void
    contactPointAffine(
      size_t   i,
      affine & pose
    ) const;

    void
    contactPointAffine(
      std::vector<affine> & pose
    ) const;

    void
    relativeAngles(
      vec3 & angles
    ) const;

    void
    relativeAngles(
      size_t   i,
      vec3   & angles
    ) const;

    void
    relativeAngles(
      std::vector<vec3> & angles
    ) const;

    void
    print(
      out_stream & os
    ) const;

  private:
    void
    refineIntersection(
      ground::mesh           const & ground,
      triangleground::vecptr const & local_ground,
      bool                           refine
    );

  }; // class shell

} // namespace enve

#endif