1 /* Siconos is a program dedicated to modeling, simulation and control 2 * of non smooth dynamical systems. 3 * 4 * Copyright 2021 INRIA. 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 /*! \file RigidBody2dDS.hpp 20 \brief Definition of an abstract 3D rigid body above NewtonEulerDS 21 */ 22 23 24 #ifndef RigidBody2dDS_h 25 #define RigidBody2dDS_h 26 27 #include <MechanicsFwd.hpp> 28 #include <LagrangianDS.hpp> 29 #include <SiconosVisitor.hpp> 30 #include <SiconosContactor.hpp> 31 32 class RigidBody2dDS : public LagrangianDS, 33 public std::enable_shared_from_this<RigidBody2dDS> 34 { 35 protected: 36 /** serialization hooks 37 */ 38 ACCEPT_SERIALIZATION(RigidBody2dDS); 39 RigidBody2dDS()40 RigidBody2dDS() : LagrangianDS() {}; 41 42 /** a scalar mass in the case of RigidBody2dDS */ 43 double _scalarMass; 44 45 SP::SiconosContactorSet _contactors; 46 bool _useContactorInertia; 47 48 /** If false, bodies connected to this body by a joint will not 49 * collide. See also NewtonEulerJointR::_allowSelfCollide */ 50 bool _allowSelfCollide = true; 51 52 public: 53 54 RigidBody2dDS(SP::SiconosVector position, 55 SP::SiconosVector velocity, 56 SP::SiconosMatrix mass = SP::SimpleMatrix()); 57 58 RigidBody2dDS(SP::SiconosVector position, 59 SP::SiconosVector velocity, 60 double mass, 61 double inertia); 62 63 virtual ~RigidBody2dDS(); 64 scalarMass()65 double scalarMass() 66 { 67 return _scalarMass; 68 }; 69 70 setUseContactorInertia(bool use)71 void setUseContactorInertia(bool use) { _useContactorInertia = use; } 72 useContactorInertia()73 bool useContactorInertia() { return _useContactorInertia; } 74 75 /** Return the value of the _allowSelfCollide flag. */ allowSelfCollide()76 bool allowSelfCollide() { return _allowSelfCollide; } 77 78 /** Set the value of the _allowSelfCollide flag. */ setAllowSelfCollide(bool x)79 void setAllowSelfCollide(bool x) { _allowSelfCollide = x; } 80 81 /** Access the contactor set associated with this body. 82 * \return A SP::SiconosContactorSet */ contactors() const83 SP::SiconosContactorSet contactors() const { return _contactors; } 84 85 /** Provide a set of contactors to the body. 86 * \param c A SP::SiconosContactorSet */ setContactors(SP::SiconosContactorSet c)87 void setContactors(SP::SiconosContactorSet c) { _contactors = c; } 88 89 /** Make the base position of the contactors equal to the DS q vector. 90 * \return a SP::SiconosVector */ base_position()91 virtual SP::SiconosVector base_position() { return q(); } 92 93 /** visitors hook 94 */ 95 ACCEPT_BASE_VISITORS(LagrangianDS); 96 }; 97 98 #endif /* RigidBody2dDS_h */ 99