Program Listing for File mesh.hxx

Return to documentation for file (src/enve/mesh.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_MESH_HXX
#define INCLUDE_ENVE_MESH_HXX

#include "triangleground.hxx"

namespace enve
{

  namespace ground
  {

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

    class mesh
    {
    private:
      triangleground::vecptr m_triangles;
      aabb::vecptr           m_bboxes;
      AABBtree::ptr          m_AABBtree;

    public:
      mesh(mesh const &) = delete;

      mesh(mesh &&) = delete;

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

      mesh & operator=(mesh &&) = delete;

      ~mesh(void) = default;

      mesh(void);

      mesh(
        triangleground::vecptr const & triangles
      );

      mesh(
        std::string const & path
      );

      mesh(
        std::string const & path,
        real                friction
      );

      void
      copy(
        mesh const & mesh_obj
      );

      void
      clear(void);

      triangleground::vecptr const &
      vecptrTriangleground(void)
      const;

      triangleground::ptr
      ptrTriangleground(
        size_t i
      ) const;

      triangleground::ptr
      operator[](
        size_t i
      ) const;

      void
      print(
        std::string const & path
      ) const;

      size_t
      size(void)
      const;

      bool
      load(
        std::string const & path
      );

      bool
      load(
        std::string const & path,
        real                friction
      );

      bool
      intersection(
        aabb::ptr              const   box,
        triangleground::vecptr       & triangles
      ) const;

      void
      buildAABBtree(void);

    private:
      void
      updateBBoxes(void);

      void
      split(
        std::string              const & in,
        std::vector<std::string>       & out,
        std::string              const & token
      ) const;

      std::string
      tail(
        std::string const & in
      ) const;

      std::string
      firstToken(
        std::string const & in
      ) const;

    };

  } // namespace ground

} // namespace enve

#endif