7 #ifndef _TRIANGLE_MESH_PRIMITIVE_H
8 #define _TRIANGLE_MESH_PRIMITIVE_H
16 #include <Moby/Types.h>
17 #include <Moby/Primitive.h>
30 virtual double get_bounding_radius()
const {
return 0.0; }
35 virtual void load_from_xml(boost::shared_ptr<const XMLTree> node, std::map<std::string, BasePtr>& id_map);
36 virtual void save_to_xml(
XMLTreePtr node, std::list<boost::shared_ptr<const Base> >& shared_objects)
const;
38 virtual void get_vertices(boost::shared_ptr<const Ravelin::Pose3d> P, std::vector<Point3d>& vertices)
const;
40 virtual boost::shared_ptr<const IndexedTriArray>
get_mesh(boost::shared_ptr<const Ravelin::Pose3d> P) {
return _mesh; }
41 void set_mesh(boost::shared_ptr<const IndexedTriArray> mesh);
42 virtual void set_pose(
const Ravelin::Pose3d& T);
49 virtual void calc_mass_properties();
52 bool _convexify_inertia;
55 std::map<CollisionGeometryPtr, BVPtr> _roots;
61 boost::shared_ptr<const IndexedTriArray> _mesh;
64 double _edge_sample_length;
67 class AThickTri :
public ThickTriangle
70 AThickTri(
const Triangle& tri,
double tol) : ThickTriangle(tri, tol) {}
71 boost::shared_ptr<const IndexedTriArray> mesh;
75 void construct_mesh_vertices(boost::shared_ptr<const IndexedTriArray> mesh,
CollisionGeometryPtr geom);
77 void split_tris(
const Point3d& point,
const Ravelin::Vector3d& normal,
const IndexedTriArray& orig_mesh,
const std::list<unsigned>& ofacets, std::list<unsigned>& pfacets, std::list<unsigned>& nfacets);
78 bool split(boost::shared_ptr<const IndexedTriArray> mesh,
BVPtr source,
BVPtr& tgt1,
BVPtr& tgt2,
const Ravelin::Vector3d& axis);
80 template <
class InputIterator,
class OutputIterator>
81 static OutputIterator
get_vertices(
const IndexedTriArray& tris, InputIterator fselect_begin, InputIterator fselect_end, OutputIterator output, boost::shared_ptr<const Ravelin::Pose3d> P);
84 std::map<BVPtr, std::list<unsigned> > _mesh_tris;
87 std::vector<Point3d> _vertices;
90 std::map<BVPtr, std::list<unsigned> > _mesh_vertices;
93 std::map<BVPtr, std::list<boost::shared_ptr<AThickTri> > > _tris;
96 std::pair<boost::shared_ptr<const IndexedTriArray>, std::list<unsigned> > _smesh;
99 #include "TriangleMeshPrimitive.inl"
virtual void save_to_xml(XMLTreePtr node, std::list< boost::shared_ptr< const Base > > &shared_objects) const
Implements Base::save_to_xml()
Definition: TriangleMeshPrimitive.cpp:253
boost::shared_ptr< BV > BVPtr
Bounding volume (BV) smart pointer.
Definition: Types.h:92
virtual boost::shared_ptr< const IndexedTriArray > get_mesh(boost::shared_ptr< const Ravelin::Pose3d > P)
Gets the underlying triangle mesh for this primitive.
Definition: TriangleMeshPrimitive.h:40
virtual bool is_convex() const
Returns whether the mesh is convex (currently mesh must be convex)
Definition: TriangleMeshPrimitive.cpp:411
TriangleMeshPrimitive()
Creates the triangle mesh primitive.
Definition: TriangleMeshPrimitive.cpp:48
virtual double calc_dist_and_normal(const Point3d &point, std::vector< Ravelin::Vector3d > &normals) const
Computes the distance and normal from a point on the mesh.
Definition: TriangleMeshPrimitive.cpp:455
Defines a triangle-mesh-based primitive type used for inertial property calculation and geometry prov...
Definition: Primitive.h:41
void set_edge_sample_length(double len)
Sets the edge sample length for this triangle mesh.
Definition: TriangleMeshPrimitive.cpp:101
virtual osg::Node * create_visualization()
Creates the visualization for this primitive.
Definition: TriangleMeshPrimitive.cpp:111
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
Ravelin::Vector3d Point3d
Typedef to distinguish between a 3D vector and a point.
Definition: Types.h:47
virtual void get_vertices(boost::shared_ptr< const Ravelin::Pose3d > P, std::vector< Point3d > &vertices) const
Get vertices corresponding to this primitive.
double get_edge_sample_length() const
Gets the length of an edge in the mesh above which point sub-samples are created. ...
Definition: TriangleMeshPrimitive.h:32
virtual BVPtr get_BVH_root(CollisionGeometryPtr geom)
Gets the pointer to the root bounding box.
Definition: TriangleMeshPrimitive.cpp:400
void set_mesh(boost::shared_ptr< const IndexedTriArray > mesh)
Sets the mesh.
Definition: TriangleMeshPrimitive.cpp:300
virtual void load_from_xml(boost::shared_ptr< const XMLTree > node, std::map< std::string, BasePtr > &id_map)
Implements Base::load_from_xml()
Definition: TriangleMeshPrimitive.cpp:193
virtual void set_pose(const Ravelin::Pose3d &T)
Transforms this primitive.
Definition: TriangleMeshPrimitive.cpp:742
Represents a triangle mesh "primitive" for inertia properties, collision detection, and visualization.
Definition: TriangleMeshPrimitive.h:22
virtual double calc_signed_dist(const Point3d &p) const
Computes the signed distance to a point from the mesh.
Definition: TriangleMeshPrimitive.cpp:417