30 #ifndef _libDEM_SupportShapeT_tpp_
31 #define _libDEM_SupportShapeT_tpp_
53 template<
typename shape>
64 static bool exist(
const std::string& ID);
74 virtual std::string
info()
const;
90 virtual std::ostream&
write_ascii(std::ostream& out)
const;
91 virtual std::istream&
read_ascii(std::istream& in);
101 template<
class Archive>
void serialize(Archive & ar,
const unsigned int );
111 for (
unsigned int i = 0; i<set.
size(); ++i) {
115 UserAssert(0,
"can't find discrete shape " +
id);
119 template<
typename shape>
bool
122 for (
unsigned int i = 0; i<set.
size(); ++i) {
129 template<
typename shape>
134 "shape must be a descendant of the Shape::Base<T>");
137 template<
typename shape>
142 "shape must be a descendant of the Shape::Base<T>");
145 template<
typename shape>
150 "shape must be a descendant of the Shape::Base<T>");
153 template<
typename shape>
157 template<
typename shape> std::string
159 std::ostringstream os;
161 << shape::info() <<
'\n';
165 template<
typename shape>
void
168 shape::read_xml_element(el);
184 return *
static_cast<const shape*
>(
this);
187 template<
typename shape>
190 return *
static_cast<shape*
>(
this);
193 template<
typename shape> std::string
195 return shape::class_ID();
198 template<
typename shape>
void
202 get_boundary().init_setof();
203 get_boundary().new_setof();
204 init_boundary(*
this, set);
210 template<
typename shape>
void
213 get_boundary().init_setof();
214 get_boundary().recover_setof();
218 template<
class shape> std::ostream&
221 shape::write_ascii(out);
225 template<
class shape> std::istream&
228 shape::read_ascii(in);
232 template<
class shape> std::ostream&
234 shape::write_ascii(out);
238 template<
class shape> std::istream&
240 shape::read_ascii(in);
244 template<
typename shape>
template<
class Archive>
void
246 ar & boost::serialization::base_object<shape>(*
this);
247 ar & boost::serialization::base_object<SupportShape>(*
this);
262 template<
class shape>
263 struct Read<DEM::SupportShapeT<shape> >
279 GRANOO_CLASS_DECLARE_TPL(DEM::SupportShapeT<Shape::Sphere>);
280 GRANOO_CLASS_DECLARE_TPL(DEM::SupportShapeT<Shape::Box>);
281 GRANOO_CLASS_DECLARE_TPL(DEM::SupportShapeT<Shape::Cylinder>);
282 GRANOO_CLASS_DECLARE_TPL(DEM::SupportShapeT<Shape::Cone>);
283 GRANOO_CLASS_DECLARE_TPL(DEM::SupportShapeT<Shape::Polyhedron>);
#define UserAssert(condition, message)
Definition: Macro.hpp:54
virtual const std::string & get_ID() const
Definition: Base.hpp:144
Definition: ObjectFactory.hpp:235
Definition: SetOf.hpp:346
Definition: SetOf.hpp:236
a pure virtual class that represents a perfect shape associated with a collection of discrete element
Definition: SupportShape.hpp:54
void update_average_discrete_element_radius()
update the value of the mean radius
Definition: SupportShape.cpp:85
virtual std::ostream & write_ascii(std::ostream &out) const
dump the current state of the support shape in a ascii file (standard *.lgdd format)
Definition: SupportShape.cpp:146
virtual std::istream & read_ascii(std::istream &in)
update the current state of the element from an ascii file format *.lgdd
Definition: SupportShape.cpp:153
virtual void read_xml_element(const TiXmlElement *el)
read an xml element
virtual void attach_to(Core::SetOf< DiscreteElement > &set, bool update=true, double dist_factor=1.)
attach the support shape to a collection of discrete element
Definition: SupportShape.cpp:65
virtual std::string info() const
Display some useful info in the terminal
Definition: SupportShape.hpp:146
virtual void recoverer_boundary()
recover the boundaries of the support shape
Definition: SupportShape.cpp:73
a class that represents a perfect shape associated with a collection of discrete element
Definition: SupportShapeT.hpp:58
std::string shape_class_ID() const
get the class ID of the support shape ("Cylinder", "Cone", etc...)
Definition: SupportShapeT.hpp:194
void recoverer_boundary()
recover the boundaries of the support shape
Definition: SupportShapeT.hpp:211
SupportShapeT()
default constructor, for internal usage only (serialization)
Definition: SupportShapeT.hpp:146
void init_boundary(const shape &, Core::SetOf< DiscreteElement > &)
initialize the boundaries of the support shape
virtual std::istream & read_ascii_shape(std::istream &in)
for internal use only (.agdd compatibility)
Definition: SupportShapeT.hpp:239
void serialize(Archive &ar, const unsigned int)
complete serializing of the element in the *.gdd format
Definition: SupportShapeT.hpp:245
virtual std::ostream & write_ascii(std::ostream &out) const
dump the current state of the support shape in a ascii file (standard *.lgdd format)
Definition: SupportShapeT.hpp:219
SupportShapeT(const SupportShapeT< shape > &)=delete
const Shape::Base & to_base_shape() const
cast the current SupportShape to the corresponding Shape::Base
Definition: SupportShapeT.hpp:173
const Shape::Volume & to_volume_shape() const
cast the current SupportShape to the corresponding Shape::Volume
Definition: SupportShapeT.hpp:183
void read_xml_element(const TiXmlElement *el)
read an xml element
Definition: SupportShapeT.hpp:166
void update()
update the support shape length, position and orientation
virtual std::istream & read_ascii(std::istream &in)
update the current state of the element from an ascii file format *.lgdd
Definition: SupportShapeT.hpp:226
virtual std::ostream & write_ascii_shape(std::ostream &out) const
for internal use only (.agdd compatibility)
Definition: SupportShapeT.hpp:233
static bool exist(const std::string &ID)
check if the support shape with the ID exists
Definition: SupportShapeT.hpp:120
virtual std::string info() const
Display some useful info in the terminal
Definition: SupportShapeT.hpp:158
friend class boost::serialization::access
Definition: SupportShapeT.hpp:100
SupportShapeT & operator=(const SupportShapeT< shape > &)=delete
virtual ~SupportShapeT()
destructor (that does nothing particular)
Definition: SupportShapeT.hpp:154
static SupportShapeT< shape > & get(const std::string &ID)
retrieve a support shape with a given ID
Definition: SupportShapeT.hpp:109
void attach_to(Core::SetOf< DiscreteElement > &set, bool update=true, double dist_factor=1.)
attach the support shape to a collection of discrete element
Definition: SupportShapeT.hpp:199
Definition: Volume.hpp:103
Definition: Common.hpp:198
T value(details::expression_node< T > *n)
Definition: Exprtk.hpp:15070
static Base * new_object(const std::string &classID, std::istream &in)
Definition: SupportShapeT.hpp:265
Definition: SetOfManager.hpp:63