Go to the documentation of this file.
16 #ifndef SURGSIM_COLLISION_REPRESENTATION_H
17 #define SURGSIM_COLLISION_REPRESENTATION_H
19 #include <boost/thread/mutex.hpp>
22 #include <unordered_map>
23 #include <unordered_set>
49 typedef std::unordered_map<std::shared_ptr<SurgSim::Collision::Representation>,
50 std::list<std::shared_ptr<SurgSim::Collision::Contact>>>
ContactMapType;
92 virtual const std::shared_ptr<SurgSim::Math::Shape>
getShape()
const = 0;
96 virtual std::shared_ptr<SurgSim::Math::Shape>
getPosedShape();
110 void addContact(
const std::shared_ptr<Representation>& other,
111 const std::shared_ptr<SurgSim::Collision::Contact>& contact);
116 bool collidedWith(
const std::shared_ptr<Representation>& other);
120 virtual void update(
const double& dt);
143 bool ignore(
const std::shared_ptr<Representation>& representation);
150 void setIgnoring(
const std::vector<std::string>& fullNames);
160 bool isIgnoring(
const std::shared_ptr<Representation>& representation)
const;
180 bool allow(
const std::shared_ptr<Representation>& representation);
187 void setAllowing(
const std::vector<std::string>& fullNames);
197 bool isAllowing(
const std::shared_ptr<Representation>& representation)
const;
253 (COLLISION_DETECTION_TYPE_NONE)
254 (COLLISION_DETECTION_TYPE_DISCRETE)
255 (COLLISION_DETECTION_TYPE_CONTINUOUS)
256 (MAX_COLLISION_DETECTION_TYPES))
void setSelfCollisionDetectionType(CollisionDetectionType type)
Set the type of collision detection to use between this representation and itself.
Definition: Representation.cpp:57
void addContact(const std::shared_ptr< Representation > &other, const std::shared_ptr< SurgSim::Collision::Contact > &contact)
Add a contact with another representation.
Definition: Representation.cpp:122
bool allow(const std::string &fullName)
Set a collision representation to allow Only collisions with "allowed" collision representation will ...
Definition: Representation.cpp:181
bool isAllowing(const std::string &fullName) const
Is the collision representation being allowed.
Definition: Representation.cpp:249
SurgSim::DataStructures::BufferedValue< ContactMapType > & getCollisions()
A map between collision representations and contacts.
Definition: Representation.cpp:117
std::shared_ptr< Framework::Logger > m_logger
Definition: Representation.h:219
CollisionDetectionType m_selfCollisionDetectionType
The type of self collision detection.
Definition: Representation.h:226
#define SURGSIM_ENUM_TYPE
Required type of enums used by SURGSIM_SERIALIZABLE_ENUM.
Definition: Accessible.h:261
std::unordered_map< std::shared_ptr< SurgSim::Collision::Representation >, std::list< std::shared_ptr< SurgSim::Collision::Contact > > > ContactMapType
Definition: Representation.h:47
CollisionDetectionType getSelfCollisionDetectionType() const
Get the type of collision detection used between this representation and itself.
Definition: Representation.cpp:62
PosedShapeMotion is embedding the motion of a PosedShape, providing a posed shape at 2 different inst...
Definition: Shape.h:145
void invalidatePosedShapeMotion()
Invalidate the cached posed shape motion.
Definition: Representation.cpp:110
virtual void updateDcdData()
Update the data (the shape) in preparation for a DCD contact calculation.
Definition: Representation.cpp:292
CollisionDetectionType getCollisionDetectionType() const
Get the type of collision detection used between this representation and other representations.
Definition: Representation.cpp:52
bool isIgnoring(const std::string &fullName) const
Is the collision representation being ignored.
Definition: Representation.cpp:235
std::vector< std::string > getAllowing() const
Get the only collision representations that this representation is allowed to collide with.
Definition: Representation.cpp:274
Definition: CompoundShapeToGraphics.cpp:29
virtual void updateShapeData()
Update the basic Shape's state from the physics state, so that the bounding box can correctly be dete...
Definition: Representation.cpp:302
CollisionDetectionType m_collisionDetectionType
The type of collision detection.
Definition: Representation.h:223
virtual void update(const double &dt)
Update the representation.
Definition: Representation.cpp:136
Representation(const std::string &name)
Constructor.
Definition: Representation.cpp:28
The type of collision detection.
Definition: Representation.h:60
Math::Aabbd getBoundingBox() const
Definition: Representation.cpp:286
bool ignore(const std::string &fullName)
Set a collision representation to ignore Collisions with this collision representation will not be de...
Definition: Representation.cpp:144
virtual int getShapeType() const =0
Get the shape type id.
Eigen::AlignedBox< double, 3 > Aabbd
Wrapper around the Eigen type.
Definition: Aabb.h:30
Representations are manifestations of a SceneElement.
Definition: Representation.h:33
void setCollisionDetectionType(CollisionDetectionType type)
Set the type of collision detection to use between this representation and other representations.
Definition: Representation.cpp:47
void doRetire() override
Interface to be implemented by derived classes Has a default implementation, does nothing.
Definition: Representation.cpp:279
SURGSIM_SERIALIZABLE_ENUM(SurgSim::Devices::HandType,(HANDTYPE_LEFT)(HANDTYPE_RIGHT))
std::unordered_set< std::string > m_ignoring
Ignored collision representations.
Definition: Representation.h:243
SurgSim::DataStructures::BufferedValue< ContactMapType > m_collisions
A map which associates a list of contacts with each collision representation.
Definition: Representation.h:231
boost::shared_mutex m_posedShapeMotionMutex
Mutex to lock write access to m_posedShapeMotion.
Definition: Representation.h:240
std::unordered_set< std::string > m_allowing
Allowed collision representations.
Definition: Representation.h:246
virtual std::shared_ptr< SurgSim::Math::Shape > getPosedShape()
Get the shape, posed.
Definition: Representation.cpp:81
virtual const std::shared_ptr< SurgSim::Math::Shape > getShape() const =0
Get the shape.
const Math::PosedShapeMotion< std::shared_ptr< Math::Shape > > & getPosedShapeMotion() const
Definition: Representation.cpp:67
void setAllowing(const std::vector< std::string > &fullNames)
Set the only collision representations to allow collisions with Only Collisions with these collision ...
Definition: Representation.cpp:260
std::vector< std::string > getIgnoring() const
Get the ignored collision representations.
Definition: Representation.cpp:230
bool collidedWith(const std::shared_ptr< Representation > &other)
Check whether this collision representation collided with another during the last update.
Definition: Representation.cpp:130
virtual ~Representation()
Destructor.
Definition: Representation.cpp:42
string(TOUPPER ${DEVICE} DEVICE_UPPER_CASE) option(BUILD_DEVICE_$
Definition: CMakeLists.txt:38
boost::mutex m_collisionsMutex
Mutex to lock write access to m_collisions.
Definition: Representation.h:234
Math::PosedShapeMotion< std::shared_ptr< Math::Shape > > m_posedShapeMotion
The shape transformed in space and defined through time, i.e. with 2 differents configurations.
Definition: Representation.h:237
void setPosedShapeMotion(const Math::PosedShapeMotion< std::shared_ptr< Math::Shape >> &posedShape)
Definition: Representation.cpp:74
void setIgnoring(const std::vector< std::string > &fullNames)
Set the collision representations to ignore Collisions with these collision representation will not b...
Definition: Representation.cpp:216
virtual void updateCcdData(double timeOfImpact)
Update the data (the motionShape) in preparation for a CCD contact calcul ation.
Definition: Representation.cpp:297