GranOO 3.0
A robust and versatile workbench to build 3D dynamic simulations based on the Discrete Element Method
Loading...
Searching...
No Matches
Disk.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 _GranOO_LibShape_Disk_hh_
31#define _GranOO_LibShape_Disk_hh_
32
33#include <iostream>
34#include <string>
35
36#include <vtkUnstructuredGrid.h>
37
39
42
45
46namespace GranOO3
47{
48 namespace Shape
49 {
50
51 class Disk : public Surface,
52 public Core::ObjectFactoryInterface< Base, Disk>
53 {
54
55 GRANOO_OBJECT_FACTORY(Disk);
56
57 public:
58 static std::string class_ID() {return std::string("Disk");}
59 static std::string desc();
60
61 public:
62 Disk();
63 Disk(double radius, const Geom::Frame& frame);
64 Disk(const Disk &);
65 Disk(const Geom::Frame& frame);
66 ~Disk();
67
68 //USEFULL
69 void read_xml_element(const TiXmlElement* el);
70 std::string description() const;
71 std::string get_str_type_key() const;
72 double area() const;
73
74 //ACCESSORS
75 GRANOO_ACCESS_POS(radius, double, _radius);
76
77 void draw_gl() const;
78 void scale(double);
79
80 //CONTACT DETECTION v2
81 bool collide(const Volume&, Collision::Data&) const;
82 bool collide(const Geom::Point&, Collision::Data&) const;
83
84 virtual void to_vtk(vtkUnstructuredGrid* data);
85 std::ostream& to_povray (std::ostream& out, const Core::Color& ) const;
86
87
88 private:
90 template<class Archive> void serialize(Archive & ar, const unsigned int );
91
92 private:
93 double _radius;
94 };
95
96
97 inline
98 Disk::Disk(double radius, const Geom::Frame& frame)
99 : Surface(frame),
100 _radius(radius) {
101 SafeModeAssert(_radius>=0, "bad input value");
102 }
103
104 inline
106 : Disk(0, Geom::Frame::global) {
107 }
108
109 inline
110 Disk::Disk(const Disk& p)
111 : Surface(p.local_frame()),
112 _radius(p.get_radius()) {
113 SafeModeAssert(_radius>=0, "bad input value");
114 }
115
116 inline
118 : Surface(frame),
119 _radius(0.) {
120 }
121
122 inline
124 }
125
126 inline std::string
128 return Disk::class_ID();
129 }
130
131 inline double
132 Disk::area() const {
133 return M_PI*_radius*_radius;
134 }
135
136 template<class Archive>
137 inline void
138 Disk::serialize(Archive & ar, const unsigned int ) {
139 ar & boost::serialization::base_object<Surface>(*this);
140 ar & _radius;
141 }
142
143 }
144}
145
146//Don't forget to export for dynamic serialization of child class
147#include <boost/serialization/export.hpp>
149
150#include <boost/serialization/version.hpp>
152GRANOO_SERIALIZE_SHAPE(Disk)
153
154namespace GranOO3
155{
156 extern template class Core::ObjectFactoryInterface<Shape::Base, Shape::Disk>;
157}
158
159
160#endif
BOOST_CLASS_EXPORT_KEY(GranOO3::Shape::Box) namespace GranOO3
Definition Box.hpp:319
BOOST_CLASS_VERSION(GranOO3::Core::Base, 1) namespace GranOO3
Definition Base.hpp:277
#define SafeModeAssert(condition, message)
Definition Macro.hpp:47
Definition Color.hpp:44
Definition ObjectFactory.hpp:235
Definition Frame.hpp:68
Definition Point.hpp:62
const Geom::Frame & local_frame() const
Definition Base.hpp:133
Definition Disk.hpp:53
static std::string desc()
void read_xml_element(const TiXmlElement *el)
bool collide(const Volume &, Collision::Data &) const
std::ostream & to_povray(std::ostream &out, const Core::Color &) const
double _radius
Definition Disk.hpp:93
void scale(double)
void draw_gl() const
double area() const
Definition Disk.hpp:132
static std::string class_ID()
Definition Disk.hpp:58
void serialize(Archive &ar, const unsigned int)
Definition Disk.hpp:138
Disk()
Definition Disk.hpp:105
virtual void to_vtk(vtkUnstructuredGrid *data)
bool collide(const Geom::Point &, Collision::Data &) const
std::string description() const
friend class boost::serialization::access
Definition Disk.hpp:89
~Disk()
Definition Disk.hpp:123
std::string get_str_type_key() const
Definition Disk.hpp:127
Surface(const Geom::Frame &frame)
Definition Surface.cpp:37
Definition Volume.hpp:103
This namespace group the entire Geom library.
This namespace group the entire Shape library.
Definition Common.hpp:198
Definition Data.hpp:43