Moby
TorusPrimitive.h
1 /****************************************************************************
2  * Copyright 2015 Evan Drumwright
3  * This library is distributed under the terms of the Apache V2.0
4  * License (obtainable from http://www.apache.org/licenses/LICENSE-2.0).
5  ****************************************************************************/
6 
7 #ifndef _TORUS_PRIMITIVE_H
8 #define _TORUS_PRIMITIVE_H
9 
10 #include <Moby/Primitive.h>
11 
12 namespace Moby {
13 
14 class PlanePrimitive;
15 
17 class TorusPrimitive : public Primitive
18 {
19  public:
21  TorusPrimitive(double major_radius, double minor_radius);
22  TorusPrimitive(const Ravelin::Pose3d& T);
23  void set_radii(double major_radius, double minor_radius);
24  virtual bool is_convex() const { return false; }
25  virtual void load_from_xml(boost::shared_ptr<const XMLTree> node, std::map<std::string, BasePtr>& id_map);
26  virtual void save_to_xml(XMLTreePtr node, std::list<boost::shared_ptr<const Base> >& shared_objects) const;
28  virtual double calc_dist_and_normal(const Point3d& point, std::vector<Ravelin::Vector3d>& normals) const;
29  double calc_closest_point(const Point3d& point, Point3d& closest) const;
30  virtual boost::shared_ptr<const IndexedTriArray> get_mesh(boost::shared_ptr<const Ravelin::Pose3d> P);
31  virtual osg::Node* create_visualization();
32  virtual double calc_signed_dist(boost::shared_ptr<const Primitive> p, Point3d& pthis, Point3d& pp) const;
33  virtual double calc_signed_dist(boost::shared_ptr<const PlanePrimitive> p, Point3d& pthis, Point3d& pp) const;
34  virtual void get_vertices(boost::shared_ptr<const Ravelin::Pose3d> P, std::vector<Point3d>& p) const;
35  virtual double calc_signed_dist(const Point3d& p) const;
36  virtual double get_bounding_radius() const { return _major_radius + _minor_radius; }
37 
39  double get_major_radius() const { return _major_radius; }
40 
42  double get_minor_radius() const { return _minor_radius; }
43 
44  private:
45  virtual void calc_mass_properties();
46  static double urand(double a, double b);
47 
49  std::map<CollisionGeometryPtr, std::vector<Point3d> > _vertices;
50 
52  std::map<CollisionGeometryPtr, OBBPtr> _obbs;
53 
55  double _major_radius;
56 
58  double _minor_radius;
59 }; // end class
60 } // end namespace
61 
62 #endif
boost::shared_ptr< BV > BVPtr
Bounding volume (BV) smart pointer.
Definition: Types.h:92
virtual bool is_convex() const
Determines whether this primitive is convex.
Definition: TorusPrimitive.h:24
virtual double calc_signed_dist(boost::shared_ptr< const Primitive > p, Point3d &pthis, Point3d &pp) const
Computes the signed distance between this and another primitive.
Defines a triangle-mesh-based primitive type used for inertial property calculation and geometry prov...
Definition: Primitive.h:41
double get_major_radius() const
Gets the major radius.
Definition: TorusPrimitive.h:39
double get_minor_radius() const
Get the minor radius.
Definition: TorusPrimitive.h:42
virtual BVPtr get_BVH_root(CollisionGeometryPtr geom)
Gets the root BVH for this torus.
Definition: TorusPrimitive.cpp:77
virtual void load_from_xml(boost::shared_ptr< const XMLTree > node, std::map< std::string, BasePtr > &id_map)
Implements Base::load_from_xml() for serialization.
Definition: TorusPrimitive.cpp:355
void set_radii(double major_radius, double minor_radius)
Sets the.
Definition: TorusPrimitive.cpp:379
virtual void save_to_xml(XMLTreePtr node, std::list< boost::shared_ptr< const Base > > &shared_objects) const
Implements Base::save_to_xml() for serialization.
Definition: TorusPrimitive.cpp:401
boost::shared_ptr< CollisionGeometry > CollisionGeometryPtr
Collision geometry smart pointer.
Definition: Types.h:77
boost::shared_ptr< XMLTree > XMLTreePtr
XML tree smart pointer.
Definition: Types.h:104
virtual osg::Node * create_visualization()
Creates the visualization for this primitive.
Definition: TorusPrimitive.cpp:64
Ravelin::Vector3d Point3d
Typedef to distinguish between a 3D vector and a point.
Definition: Types.h:47
Represents a solid box centered at the origin (by default)
Definition: TorusPrimitive.h:17
virtual void get_vertices(boost::shared_ptr< const Ravelin::Pose3d > P, std::vector< Point3d > &p) const
Gets the vertices corresponding to this torus.
Definition: TorusPrimitive.cpp:113
virtual double calc_dist_and_normal(const Point3d &point, std::vector< Ravelin::Vector3d > &normals) const
Computes the distance from a point to this torus.
Definition: TorusPrimitive.cpp:108
virtual boost::shared_ptr< const IndexedTriArray > get_mesh(boost::shared_ptr< const Ravelin::Pose3d > P)
Gets the mesh corresponding to this torus.
Definition: TorusPrimitive.cpp:193