Moby
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
Moby::Primitive Class Referenceabstract

Defines a triangle-mesh-based primitive type used for inertial property calculation and geometry provisions. More...

#include <Primitive.h>

Inheritance diagram for Moby::Primitive:
Moby::Base Moby::ConePrimitive Moby::CylinderPrimitive Moby::HeightmapPrimitive Moby::PlanePrimitive Moby::PolyhedralPrimitive Moby::SpherePrimitive Moby::TorusPrimitive Moby::TriangleMeshPrimitive

Public Member Functions

 Primitive ()
 Constructs a primitive under the identity transformation.
 
 Primitive (const Ravelin::Pose3d &T)
 
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.
 
virtual void save_to_xml (XMLTreePtr node, std::list< boost::shared_ptr< const Base > > &shared_objects) const
 Implements Base::save_to_xml() for serialization.
 
void update_visualization ()
 Updates the visualization on the primitive.
 
void set_mass (double mass)
 Sets the mass of this primitive. More...
 
void set_density (double density)
 Sets the density of this primitive.
 
virtual void set_pose (const Ravelin::Pose3d &T)
 Sets the transform for this primitive – transforms mesh and inertial properties (if calculated)
 
virtual Point3d get_supporting_point (const Ravelin::Vector3d &d) const
 Gets a supporting point from a primitive.
 
virtual double calc_signed_dist (const Point3d &p) const
 Calculates the signed distance from this primitive.
 
void add_collision_geometry (CollisionGeometryPtr cg)
 Adds a collision geometry.
 
void remove_collision_geometry (CollisionGeometryPtr cg)
 Removes a collision geometry.
 
boost::shared_ptr< const
Ravelin::Pose3d > 
get_pose (CollisionGeometryPtr g) const
 Gets the pose of this primitive relative to a particular collision geometry.
 
virtual double get_bounding_radius () const =0
 
virtual double calc_max_dist (double lin_cont, double ang_cont, double dist, const Ravelin::Vector3d &d0, const Ravelin::Vector3d &w0, boost::shared_ptr< const Ravelin::Pose3d > P)
 Computes the maximum distance by a point on the geometry.
 
virtual bool is_convex () const
 Determines whether this primitive is convex.
 
virtual double calc_dist_and_normal (const Point3d &p, std::vector< Ravelin::Vector3d > &normals) const =0
 Computes the distance between a point and this primitive.
 
virtual double calc_signed_dist (boost::shared_ptr< const Primitive > p, Point3d &pthis, Point3d &pp) const =0
 Computes the signed distance between this and another primitive.
 
virtual osg::Node * get_visualization ()
 Gets the visualization for this primitive. More...
 
virtual osg::Node * create_visualization ()=0
 
virtual BVPtr get_BVH_root (CollisionGeometryPtr geom)=0
 Gets the root bounding volume for this primitive.
 
virtual void get_vertices (boost::shared_ptr< const Ravelin::Pose3d > P, std::vector< Point3d > &vertices) const =0
 Get vertices corresponding to this primitive. More...
 
boost::shared_ptr< const
Ravelin::Pose3d > 
get_inertial_pose () const
 Gets the inertial frame of this primitive.
 
boost::shared_ptr< const
Ravelin::Pose3d > 
get_pose () const
 Gets the pose of this primitive.
 
virtual boost::shared_ptr
< const IndexedTriArray
get_mesh (boost::shared_ptr< const Ravelin::Pose3d > P)=0
 Gets the underlying triangle mesh for this primitive.
 
const Ravelin::SpatialRBInertiad & get_inertia () const
 Gets the inertia for this primitive.
 
- Public Member Functions inherited from Moby::Base
 Base (const Base *b)
 

Protected Member Functions

virtual void calc_mass_properties ()=0
 

Protected Attributes

boost::shared_ptr
< Ravelin::Pose3d > 
_F
 The pose of this primitive (relative to the global frame)
 
boost::shared_ptr
< Ravelin::Pose3d > 
_jF
 The inertial pose of this primitive (relative to the global frame)
 
boost::shared_ptr< double > _density
 The density of this primitive.
 
Ravelin::SpatialRBInertiad _J
 The inertia of the primitive.
 
std::map< boost::weak_ptr
< CollisionGeometry >
, boost::shared_ptr
< Ravelin::Pose3d > > 
_cg_poses
 The poses of this primitive, relative to a collision geometry.
 
std::set< boost::shared_ptr
< Ravelin::Pose3d > > 
_poses
 The poses, relative to a particular collision geometry.
 

Friends

class CSG
 

Additional Inherited Members

- Static Public Member Functions inherited from Moby::Base
template<class T >
static boost::shared_ptr< T > clone (boost::shared_ptr< T > x)
 Static method for cloning a shared pointer.
 
- Public Attributes inherited from Moby::Base
boost::shared_ptr< void > userdata
 Any relevant userdata.
 
std::string id
 The unique ID for this object.
 

Detailed Description

Defines a triangle-mesh-based primitive type used for inertial property calculation and geometry provisions.

The center-of-mass of derived types may be at the origin of the world, or not. Additionally, Primitive can take a transformation matrix in its constructor, with which the primitive data (com, inertia matrix, and geometry) can be transformed.

Member Function Documentation

OutputIterator Primitive::get_vertices ( boost::shared_ptr< const Ravelin::Pose3d >  P,
std::vector< Point3d > &  vertices 
) const
pure virtual

Get vertices corresponding to this primitive.

Gets the vertex indices from selected facets of an IndexedTriArray.

Parameters
tristhe triangle mesh
fselect_beginiterator to a container of type unsigned (facet indices)
fselect_enditerator to a container of type unsigned (facet indices)
outputbeginning iterator to a container of type Point3d; unique vertices are copied here on return
Returns
ending iterator to a container of type Point3d; unique vertices are copied here on return

Implemented in Moby::BoxPrimitive, Moby::TriangleMeshPrimitive, Moby::ConePrimitive, Moby::CylinderPrimitive, Moby::TorusPrimitive, Moby::PolyhedralPrimitive, Moby::SpherePrimitive, Moby::PlanePrimitive, and Moby::HeightmapPrimitive.

References Moby::IndexedTri::a, Moby::IndexedTri::b, Moby::IndexedTri::c, Moby::IndexedTriArray::get_facets(), and Moby::IndexedTriArray::get_vertices().

osg::Node * Primitive::get_visualization ( )
virtual

Gets the visualization for this primitive.

Gets the visualization for this primitive, creating it if necessary.

void Primitive::set_mass ( double  mass)

Sets the mass of this primitive.

Note
sets the density too

The documentation for this class was generated from the following files: