Moby
PlanePrimitive.h
1 /****************************************************************************
2  * Copyright 2014 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 _PLANE_PRIMITIVE_H
8 #define _PLANE_PRIMITIVE_H
9 
10 #include <Moby/Primitive.h>
11 #include <Moby/OBB.h>
12 
13 namespace Moby {
14 
15 class CylinderPrimitive;
16 class SpherePrimitive;
17 class BoxPrimitive;
18 class PolyhedralPrimitive;
19 
21 class PlanePrimitive : public Primitive
22 {
23  friend class CCD;
24 
25  public:
27  PlanePrimitive(const Ravelin::Pose3d& T);
28  virtual Point3d get_supporting_point(const Ravelin::Vector3d& dir) const;
29  virtual void set_pose(const Ravelin::Pose3d& T);
30  virtual void get_vertices(boost::shared_ptr<const Ravelin::Pose3d> P, std::vector<Point3d>& vertices) const;
31  void get_vertices(BVPtr bv, boost::shared_ptr<const Ravelin::Pose3d> P, std::vector<Point3d>& vertices) const;
32  virtual double calc_dist_and_normal(const Point3d& point, std::vector<Ravelin::Vector3d>& normals) const;
33  virtual double calc_signed_dist(boost::shared_ptr<const Primitive> p, Point3d& pthis, Point3d& pp) const;
34  double calc_signed_dist(boost::shared_ptr<const PolyhedralPrimitive> b, Point3d& pthis, Point3d& pb) const;
35  double calc_signed_dist(boost::shared_ptr<const CylinderPrimitive> s, Point3d& pthis, Point3d& psph) const;
36  double calc_signed_dist(boost::shared_ptr<const SpherePrimitive> s, Point3d& pthis, Point3d& psph) const;
37  virtual double calc_signed_dist(const Point3d& p) const;
38  virtual osg::Node* create_visualization();
39  virtual boost::shared_ptr<const IndexedTriArray> get_mesh(boost::shared_ptr<const Ravelin::Pose3d> P);
40  virtual void calc_mass_properties() { _density.reset(); _J.set_zero(); }
42  virtual void load_from_xml(boost::shared_ptr<const XMLTree> node, std::map<std::string, BasePtr>& id_map);
43  virtual void save_to_xml(XMLTreePtr node, std::list<boost::shared_ptr<const Base> >& shared_objects) const;
44  virtual bool is_convex() const { return true; }
45  virtual double get_bounding_radius() const { return 0.0; }
46 
47  protected:
48  virtual double calc_height(const Point3d& p) const;
49 
51  std::map<CollisionGeometryPtr, boost::shared_ptr<OBB> > _obbs;
52 
53 }; // end class
54 
55 } // end namespace
56 
57 #endif
boost::shared_ptr< BV > BVPtr
Bounding volume (BV) smart pointer.
Definition: Types.h:92
std::map< CollisionGeometryPtr, boost::shared_ptr< OBB > > _obbs
The bounding volumes for the heightmap.
Definition: PlanePrimitive.h:51
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: PlanePrimitive.cpp:495
virtual double calc_dist_and_normal(const Point3d &point, std::vector< Ravelin::Vector3d > &normals) const
Finds the signed distance betwen the plane and a point.
Definition: PlanePrimitive.cpp:477
Defines a triangle-mesh-based primitive type used for inertial property calculation and geometry prov...
Definition: Primitive.h:41
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.
virtual void set_pose(const Ravelin::Pose3d &T)
Transforms the primitive.
Definition: PlanePrimitive.cpp:59
virtual double calc_height(const Point3d &p) const
Computes the height at a particular point.
Definition: PlanePrimitive.cpp:152
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 void save_to_xml(XMLTreePtr node, std::list< boost::shared_ptr< const Base > > &shared_objects) const
Implements Base::save_to_xml() for serialization.
Definition: PlanePrimitive.cpp:505
virtual bool is_convex() const
Determines whether this primitive is convex.
Definition: PlanePrimitive.h:44
Ravelin::Vector3d Point3d
Typedef to distinguish between a 3D vector and a point.
Definition: Types.h:47
PlanePrimitive()
Initializes the heightmap primitive.
Definition: PlanePrimitive.cpp:41
boost::shared_ptr< double > _density
The density of this primitive.
Definition: Primitive.h:109
Implements the CollisionDetection abstract class to perform exact contact finding using abstract shap...
Definition: CCD.h:36
virtual osg::Node * create_visualization()
Computes the OSG visualization.
Definition: PlanePrimitive.cpp:183
Represents a heightmap with height zero on the xz plane (primitive can be transformed) ...
Definition: PlanePrimitive.h:21
Ravelin::SpatialRBInertiad _J
The inertia of the primitive.
Definition: Primitive.h:112
virtual BVPtr get_BVH_root(CollisionGeometryPtr geom)
Gets the BVH root for the heightmap.
Definition: PlanePrimitive.cpp:72
virtual Point3d get_supporting_point(const Ravelin::Vector3d &dir) const
Gets the supporting point for the plane (for GJK)
Definition: PlanePrimitive.cpp:161
virtual void get_vertices(boost::shared_ptr< const Ravelin::Pose3d > P, std::vector< Point3d > &vertices) const
Get vertices corresponding to this primitive.
virtual boost::shared_ptr< const IndexedTriArray > get_mesh(boost::shared_ptr< const Ravelin::Pose3d > P)
Gets the mesh of the heightmap.
Definition: PlanePrimitive.cpp:51