GranOO 3.0
A robust and versatile workbench to build 3D dynamic simulations based on the Discrete Element Method
Loading...
Searching...
No Matches
BodyT.hpp
Go to the documentation of this file.
1// This file is part of GranOO, a workbench for DEM simulation.
2//
3// Author(s) : - Damien Andre IRCER/UNILIM, Limoges France
4// <damien.andre@unilim.fr>
5// - Jean-luc Charles Arts et Metiers ParisTech, CNRS, I2M, Bordeaux France
6// <jean-luc.charles@ensam.eu>
7// - Jeremie Girardot Arts et Metiers ParisTech, CNRS, I2M, Bordeaux France
8// <jeremie.girardot@ensam.eu>
9// - Cedric Hubert LAMIH/UPHF, Valenciennes France
10// <cedric.hubert@uphf.fr>
11// - Ivan Iordanoff Arts et Metiers ParisTech, CNRS, I2M, Bordeaux France
12// <ivan.iordanoff@ensam.eu>
13//
14// Copyright (C) 2008-2019 D. Andre, JL. Charles, J. Girardot, C. Hubert, I. Iordanoff
15//
16// This program is free software: you can redistribute it and/or modify
17// it under the terms of the GNU General Public License as published by
18// the Free Software Foundation, either version 3 of the License, or
19// (at your option) any later version.
20//
21// This program is distributed in the hope that it will be useful,
22// but WITHOUT ANY WARRANTY; without even the implied warranty of
23// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24// GNU General Public License for more details.
25//
26// You should have received a copy of the GNU General Public License
27// along with this program. If not, see <http://www.gnu.org/licenses/>.
28
29
30#ifndef _LibPhysic_BodyT_H
31#define _LibPhysic_BodyT_H
32
33#include <type_traits>
34
37
38#include "GranOO3/Core/Prop.hpp"
39
40// Volume shape
42#include "GranOO3/Shape/Box.hpp"
46
47
48namespace GranOO3
49{
50 namespace Physic
51 {
52
53 template<class shape>
54 class BodyT : public Body,
55 public shape,
56 public Core::Register< BodyT<shape> >
57 {
58
59 GRANOO_CLASS_T(Physic::BodyT, shape, Body);
60
61 public:
62 // Constructors and destructor
63 BodyT(const Geom::Point & p, const Geom::Quaternion& q, double mass, const Geom::Tensor& tensor);
65 virtual ~BodyT();
66
67 GRANOO_ACCESS_REF_CONST(local_frame, Geom::Frame, Node::local_frame());
68 GRANOO_ACCESS_GET (center , Geom::Point , Node::get_center() );
69 GRANOO_ACCESS (quaternion , Geom::Quaternion, Node::quaternion() );
70
71 // Useful for internal use only, NOT DOCUMENTED !
72 virtual void draw();
73 virtual void draw_edge();
74 virtual std::string info() const;
75
76 private:
77 BodyT(const BodyT&) = delete;
78 BodyT & operator=(const BodyT &) = delete;
79
80 //BOOST SERIALIZATION
82 template<class Archive> void serialize(Archive&, const unsigned int);
83 };
84
85#ifndef DOXYGEN_SHOULD_SKIP_THIS
86
87 template<class shape>
88 BodyT<shape>::BodyT(const Geom::Point & p, const Geom::Quaternion& q, double mass, const Geom::Tensor& tensor)
89 : Body(*this, p,q,mass,tensor),
90 shape(Body::local_frame()) {
91 }
92
93 template<class shape>
95 : BodyT<shape>(Geom::global::center, Geom::global::quaternion, 0., Geom::global::tensor) {
96 }
97
98 template<class shape>
100 }
101
102 template<class shape>
103 void
105#ifndef SERVER
106 Drawable::apply_color();
107 glPushMatrix();
108 glMultMatrixd(local_frame().get_glMatrix());
109 shape::draw_gl();
110 glPopMatrix();
111#endif
112 }
113
114 template<class shape>
115 void
117#ifndef SERVER
118 Drawable::apply_color();
119 glPushMatrix();
120 glMultMatrixd(local_frame().get_glMatrix());
121 shape::draw_gl_edge();
122 glPopMatrix();
123#endif
124 }
125
126
127
128 template<class shape>
129 std::string
130 BodyT<shape>::info() const {
131 std::ostringstream os;
132 os << Body::info() << '\n'
133 << shape::info();
134 return os.str();
135 }
136
137 template<class shape>
138 template<class Archive>
139 void
140 BodyT<shape>::serialize(Archive & ar, const unsigned int version) {
141 ar & boost::serialization::base_object<Body>(*this);
142 ar & boost::serialization::base_object<shape>(*this);
143 }
144
145#endif
146 }
147}
148
149
150
151namespace GranOO3
152{
153 GRANOO_CLASS_DECLARE_TPL(Physic::BodyT<Shape::Sphere>);
154 GRANOO_CLASS_DECLARE_TPL(Physic::BodyT<Shape::Box>);
155 GRANOO_CLASS_DECLARE_TPL(Physic::BodyT<Shape::Cylinder>);
156 GRANOO_CLASS_DECLARE_TPL(Physic::BodyT<Shape::Cone>);
157 GRANOO_CLASS_DECLARE_TPL(Physic::BodyT<Shape::Polyhedron>);
158}
159
160#endif
161
Definition SetOf.hpp:346
Definition Frame.hpp:68
Definition Point.hpp:62
Definition Quaternion.hpp:54
Definition Tensor.hpp:62
a class that represents a body
Definition Body.hpp:43
Body(Shape::Volume &shape, const Geom::Point &p, const Geom::Quaternion &q, double mass, const Geom::Tensor &inertia)
constructor
Definition Body.hpp:119
std::string info() const
Display some useful info in the terminal.
Definition Body.cpp:63
Definition BodyT.hpp:57
virtual void draw()
util method for GL drawing the element (used by granoo-viewer)
virtual std::string info() const
get some info on a given element
virtual ~BodyT()
destructor
BodyT(const BodyT &)=delete
virtual void draw_edge()
void serialize(Archive &, const unsigned int)
complete serializing of the element in the *.gdd format
BodyT(const Geom::Point &p, const Geom::Quaternion &q, double mass, const Geom::Tensor &tensor)
constructor
friend class boost::serialization::access
Definition BodyT.hpp:81
BodyT()
default constructor
BodyT & operator=(const BodyT &)=delete
const Geom::Frame & local_frame() const
Definition Node.hpp:262
This namespace group the entire Geom library.
This namespace group the entire Physic library.
Definition Common.hpp:198