<commit_before>// =============================================================================
// PROJECT CHRONO - http://projectchrono.org
//
// Copyright (c) 2014 projectchrono.org
// All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be found
// in the LICENSE file at the top level of the distribution and at
// http://projectchrono.org/license-chrono.txt.
//
// =============================================================================
// Authors: <NAME>
// =============================================================================
//
// Rigid terrain
//
// =============================================================================

#ifndef RIGID_TERRAIN_H
#define RIGID_TERRAIN_H

#include <string>
#include <vector>

#include "chrono/assets/ChColor.h"
#include "chrono/geometry/ChTriangleMeshConnected.h"
#include "chrono/geometry/ChTriangleMeshSoup.h"
#include "chrono/physics/ChBody.h"
#include "chrono/physics/ChSystem.h"

#include "chrono_vehicle/ChApiVehicle.h"
#include "chrono_vehicle/ChTerrain.h"

#include "chrono_thirdparty/rapidjson/document.h"

namespace chrono {
namespace vehicle {

/// @addtogroup vehicle_terrain
/// @{

/// Rigid terrain model.
/// This class implements a terrain modeled as a rigid shape which can interact
/// through contact and friction with any other bodies whose contact flag is
/// enabled. In particular, this type of terrain can be used in conjunction with
/// a ChRigidTire.
class CH_VEHICLE_API RigidTerrain : public ChTerrain {
  public:
    /// Patch type.
    enum class PatchType {
        BOX,        ///< rectangular box
        MESH,       ///< triangular mesh (from a Wavefront OBJ file)
        HEIGHT_MAP  ///< triangular mesh (generated from a gray-scale BMP height-map)
    };

    /// Definition of a patch in a rigid terrain model.
    class CH_VEHICLE_API Patch {
      public:
        virtual ~Patch() {}

        /// Set visualization color.
        void SetColor(const ChColor& color);

        /// Set texture properties.
        void SetTexture(const std::string& filename,  ///< [in] texture filename
                        float scale_x = 1,            ///< [in] texture scale in X
                        float scale_y = 1             ///< [in] texture scale in Y
        );

        /// Return a handle to the ground body.
        std::shared_ptr<ChBody> GetGroundBody() const { return m_body; }

      protected:
        Patch();

        virtual void Initialize() = 0;

        virtual bool FindPoint(const ChVector<>& loc, double& height, ChVector<>& normal) const = 0;
        virtual void ExportMeshPovray(const std::string& out_dir, bool smoothed = false) {}
        virtual void ExportMeshWavefront(const std::string& out_dir) {}

        PatchType m_type;                ///< type of this patch
        std::shared_ptr<ChBody> m_body;  ///< associated body<commit_msg>Make RigidTerrain::Patch::Initialize() public to allow dynamic creation of terrain patches<commit_after>// =============================================================================
// PROJECT CHRONO - http://projectchrono.org
//
// Copyright (c) 2014 projectchrono.org
// All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be found
// in the LICENSE file at the top level of the distribution and at
// http://projectchrono.org/license-chrono.txt.
//
// =============================================================================
// Authors: <NAME>
// =============================================================================
//
// Rigid terrain
//
// =============================================================================

#ifndef RIGID_TERRAIN_H
#define RIGID_TERRAIN_H

#include <string>
#include <vector>

#include "chrono/assets/ChColor.h"
#include "chrono/geometry/ChTriangleMeshConnected.h"
#include "chrono/geometry/ChTriangleMeshSoup.h"
#include "chrono/physics/ChBody.h"
#include "chrono/physics/ChSystem.h"

#include "chrono_vehicle/ChApiVehicle.h"
#include "chrono_vehicle/ChTerrain.h"

#include "chrono_thirdparty/rapidjson/document.h"

namespace chrono {
namespace vehicle {

/// @addtogroup vehicle_terrain
/// @{

/// Rigid terrain model.
/// This class implements a terrain modeled as a rigid shape which can interact
/// through contact and friction with any other bodies whose contact flag is
/// enabled. In particular, this type of terrain can be used in conjunction with
/// a ChRigidTire.
class CH_VEHICLE_API RigidTerrain : public ChTerrain {
  public:
    /// Patch type.
    enum class PatchType {
        BOX,        ///< rectangular box
        MESH,       ///< triangular mesh (from a Wavefront OBJ file)
        HEIGHT_MAP  ///< triangular mesh (generated from a gray-scale BMP height-map)
    };

    /// Definition of a patch in a rigid terrain model.
    class CH_VEHICLE_API Patch {
      public:
        virtual ~Patch() {}

        /// Set visualization color.
        void SetColor(const ChColor& color);

        /// Set texture properties.
        void SetTexture(const std::string& filename,  ///< [in] texture filename
                        float scale_x = 1,            ///< [in] texture scale in X
                        float scale_y = 1             ///< [in] texture scale in Y
        );

        /// Return a handle to the ground body.
        std::shared_ptr<ChBody> GetGroundBody() const { return m_body; }

        virtual void Initialize() = 0;

      protected:
        Patch();

        virtual bool FindPoint(const ChVector<>& loc, double& height, ChVector<>& normal) const = 0;
        virtual void ExportMeshPovray(const std::string& out_dir, bool smoothed = false) {}
        virtual void ExportMeshWavefront(const std::string& out_dir) {}

        PatchType m_type;                ///< type of this patch
        std::shared_ptr<ChBody> m_body;  ///< associated body
{'fraction_non_alphanumeric': 0.20281499067322367, 'fraction_numerical': 0.0027132440223842634, 'mean_word_length': 2.942513368983957, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3820539', 'n_tokens_mistral': 1678, 'n_tokens_neox': 1546, 'n_words': 504}