1 // ============================================================================= 2 // PROJECT CHRONO - http://projectchrono.org 3 // 4 // Copyright (c) 2016 projectchrono.org 5 // All right reserved. 6 // 7 // Use of this source code is governed by a BSD-style license that can be found 8 // in the LICENSE file at the top level of the distribution and at 9 // http://projectchrono.org/license-chrono.txt. 10 // 11 // ============================================================================= 12 // Authors: Nic Olsen 13 // ============================================================================= 14 15 #pragma once 16 17 #include "chrono_distributed/ChApiDistributed.h" 18 19 #include "chrono/collision/ChCollisionModelChrono.h" 20 21 namespace chrono { 22 namespace collision { 23 24 /// @addtogroup distributed_collision 25 /// @{ 26 27 /// This class adds the ability to track the axis-aligned bounding box for the entire model 28 /// so that an entire body can be classified by which sub-domains it intersects. 29 class CH_DISTR_API ChCollisionModelDistributed : public ChCollisionModelChrono { 30 public: 31 ChCollisionModelDistributed(); 32 virtual ~ChCollisionModelDistributed(); 33 34 /// Delete all inserted geometry. 35 virtual int ClearModel() override; 36 37 /// Adds a box collision shape to the model and calculates the model's new AABB 38 virtual bool AddBox(std::shared_ptr<ChMaterialSurface> material, ///< Contact material 39 double hx, ///< Half-dimension in X direction 40 double hy, ///< Half-dimension in Y direction 41 double hz, ///< Half-dimension in Z direction 42 const ChVector<>& pos = ChVector<>(), ///< Box center location 43 const ChMatrix33<>& rot = ChMatrix33<>(1) ///< Box orientation 44 ) override; 45 46 /// Adds a sphere collision shape to the model and calculates the model's new AABB 47 virtual bool AddSphere(std::shared_ptr<ChMaterialSurface> material, ///< Contact material 48 double radius, ///< Sphere radius 49 const ChVector<>& pos = ChVector<>() ///< Sphere center location 50 ) override; 51 52 /// Adds a triangle collision shape to the model 53 virtual bool AddTriangle(std::shared_ptr<ChMaterialSurface> material, ///< Contact material 54 ChVector<> A, ///< Vertex of triangle 55 ChVector<> B, ///< Vertex of triangle 56 ChVector<> C, ///< Vertex of triangle 57 const ChVector<>& pos = ChVector<>(), ///< Triangle position 58 const ChMatrix33<>& rot = ChMatrix33<>(1) ///< Triangle orientation 59 ) override; 60 61 /// Gets the axis-aligned bounding box for the entire model 62 /// Only valid at beginning of simulation 63 virtual void GetAABB(ChVector<>& bbmin, ChVector<>& bbmax) const override; 64 65 std::vector<real3> shape_aabb_max; ///< Upper AABB corners for each shape in model 66 std::vector<real3> shape_aabb_min; ///< Lower AABB corners for each shape in model 67 68 protected: 69 ChVector<double> aabb_max; ///< Upper corner of model AABB 70 ChVector<double> aabb_min; ///< Lower corner of model AABB 71 72 bool aabb_valid; ///< Indicates that the bounding box has been computed 73 }; 74 75 /// @} distributed_collision 76 77 } // namespace collision 78 } // namespace chrono 79