Description

Class defining the geometric model for collision detection.

A ChCollisionModel contains all geometric shapes on a rigid body, for collision purposes.

#include <ChCollisionModel.h>

Inheritance diagram for chrono::collision::ChCollisionModel:
Collaboration diagram for chrono::collision::ChCollisionModel:

Public Member Functions

virtual ChCollisionSystemType GetType () const =0
 Return the type of this collision model.
 
virtual int ClearModel ()=0
 Delete all inserted geometries. More...
 
virtual int BuildModel ()=0
 Complete the construction of the collision model. More...
 
virtual bool AddSphere (std::shared_ptr< ChMaterialSurface > material, double radius, const ChVector<> &pos=ChVector<>())=0
 Add a sphere shape to this collision model. More...
 
virtual bool AddEllipsoid (std::shared_ptr< ChMaterialSurface > material, double rx, double ry, double rz, const ChVector<> &pos=ChVector<>(), const ChMatrix33<> &rot=ChMatrix33<>(1))=0
 Add an ellipsoid shape to this collision model. More...
 
virtual bool AddBox (std::shared_ptr< ChMaterialSurface > material, double hx, double hy, double hz, const ChVector<> &pos=ChVector<>(), const ChMatrix33<> &rot=ChMatrix33<>(1))=0
 Add a box shape to this collision model. More...
 
virtual bool AddCylinder (std::shared_ptr< ChMaterialSurface > material, double rx, double rz, double hy, const ChVector<> &pos=ChVector<>(), const ChMatrix33<> &rot=ChMatrix33<>(1))=0
 Add a cylinder to this collision model (default axis in Y direction). More...
 
virtual bool AddCylindricalShell (std::shared_ptr< ChMaterialSurface > material, double radius, double hlen, const ChVector<> &pos=ChVector<>(), const ChMatrix33<> &rot=ChMatrix33<>(1))=0
 Add a cylindrical shell to this collision model (default axis in Y direction). More...
 
virtual bool AddCone (std::shared_ptr< ChMaterialSurface > material, double rx, double rz, double hy, const ChVector<> &pos=ChVector<>(), const ChMatrix33<> &rot=ChMatrix33<>(1))=0
 Add a cone to this collision model (default axis on Y direction). More...
 
virtual bool AddCapsule (std::shared_ptr< ChMaterialSurface > material, double radius, double hlen, const ChVector<> &pos=ChVector<>(), const ChMatrix33<> &rot=ChMatrix33<>(1))=0
 Add a capsule to this collision model (default axis in Y direction). More...
 
virtual bool AddRoundedBox (std::shared_ptr< ChMaterialSurface > material, double hx, double hy, double hz, double sphere_r, const ChVector<> &pos=ChVector<>(), const ChMatrix33<> &rot=ChMatrix33<>(1))=0
 Add a rounded box shape to this collision model. More...
 
virtual bool AddRoundedCylinder (std::shared_ptr< ChMaterialSurface > material, double rx, double rz, double hy, double sphere_r, const ChVector<> &pos=ChVector<>(), const ChMatrix33<> &rot=ChMatrix33<>(1))=0
 Add a rounded cylinder to this collision model (default axis on Y direction). More...
 
virtual bool AddRoundedCone (std::shared_ptr< ChMaterialSurface > material, double rx, double rz, double hy, double sphere_r, const ChVector<> &pos=ChVector<>(), const ChMatrix33<> &rot=ChMatrix33<>(1))=0
 Add a rounded cone to this collision model (default axis on Y direction). More...
 
virtual bool AddConvexHull (std::shared_ptr< ChMaterialSurface > material, const std::vector< ChVector< double >> &pointlist, const ChVector<> &pos=ChVector<>(), const ChMatrix33<> &rot=ChMatrix33<>(1))=0
 Add a convex hull to this collision model. More...
 
virtual bool AddTriangleMesh (std::shared_ptr< ChMaterialSurface > material, std::shared_ptr< geometry::ChTriangleMesh > trimesh, bool is_static, bool is_convex, const ChVector<> &pos=ChVector<>(), const ChMatrix33<> &rot=ChMatrix33<>(1), double sphereswept_thickness=0.0)=0
 Add a triangle mesh to this collision model. More...
 
virtual bool AddBarrel (std::shared_ptr< ChMaterialSurface > material, double Y_low, double Y_high, double R_vert, double R_hor, double R_offset, const ChVector<> &pos=ChVector<>(), const ChMatrix33<> &rot=ChMatrix33<>(1))=0
 Add a barrel-like shape to this collision model (main axis on Y direction). More...
 
virtual bool Add2Dpath (std::shared_ptr< ChMaterialSurface > material, std::shared_ptr< geometry::ChLinePath > mpath, const ChVector<> &pos=ChVector<>(), const ChMatrix33<> &rot=ChMatrix33<>(1), const double thickness=0.001)
 Add a 2D closed line, defined on the XY plane passing by pos and aligned as rot, that defines a 2D collision shape that will collide with another 2D line of the same type if aligned on the same plane. More...
 
virtual bool AddPoint (std::shared_ptr< ChMaterialSurface > material, double radius=0, const ChVector<> &pos=ChVector<>())
 Add a point-like sphere, that will collide with other geometries, but won't ever create contacts between them. More...
 
virtual bool AddCopyOfAnotherModel (ChCollisionModel *another)=0
 Add all shapes already contained in another model. More...
 
virtual bool AddConvexHullsFromFile (std::shared_ptr< ChMaterialSurface > material, ChStreamInAscii &mstream, const ChVector<> &pos=ChVector<>(), const ChMatrix33<> &rot=ChMatrix33<>(1))
 Add a cluster of convex hulls specified in a '.chulls' file description. More...
 
ChContactableGetContactable ()
 Get the pointer to the contactable object.
 
virtual void SetContactable (ChContactable *mc)
 Set the pointer to the contactable object. More...
 
virtual ChPhysicsItemGetPhysicsItem ()
 Get the pointer to the client owner ChPhysicsItem. More...
 
virtual void SyncPosition ()=0
 Synchronize the position and orientation of the collision model to the associated contactable.
 
virtual void SetFamily (int mfamily)
 By default, all collision objects belong to family n.0, but you can set family in range 0..15. More...
 
virtual int GetFamily ()
 
virtual void SetFamilyMaskNoCollisionWithFamily (int mfamily)
 By default, family mask is all turned on, so all families can collide with this object, but you can turn on-off some bytes of this mask so that some families do not collide. More...
 
virtual void SetFamilyMaskDoCollisionWithFamily (int mfamily)
 
virtual bool GetFamilyMaskDoesCollisionWithFamily (int mfamily)
 Tells if the family mask of this collision object allows for the collision with another collision object belonging to a given family. More...
 
virtual short int GetFamilyGroup () const
 Return the collision family group of this model. More...
 
virtual void SetFamilyGroup (short int group)
 Set the collision family group of this model. More...
 
virtual short int GetFamilyMask () const
 Return the collision mask for this model. More...
 
virtual void SetFamilyMask (short int mask)
 Set the collision mask for this model. More...
 
virtual void SetSafeMargin (double amargin)
 Set the suggested collision 'inward safe margin' for the shapes to be added from now on, using the AddBox, AddCylinder etc (where, if this margin is too high for some thin or small shapes, it may be clamped). More...
 
virtual float GetSafeMargin ()
 Returns the inward safe margin (see SetSafeMargin() )
 
virtual void SetEnvelope (double amargin)
 Set the suggested collision outward 'envelope' (used from shapes added, from now on, to this collision model). More...
 
virtual float GetEnvelope ()
 Return the outward safe margin (see SetEnvelope() )
 
virtual void GetAABB (ChVector<> &bbmin, ChVector<> &bbmax) const =0
 Return the axis aligned bounding box (AABB) of the collision model, i.e. More...
 
virtual void ArchiveOUT (ChArchiveOut &marchive)
 Method to allow serialization of transient data to archives.
 
virtual void ArchiveIN (ChArchiveIn &marchive)
 Method to allow de-serialization of transient data from archives.
 
int GetNumShapes () const
 Return the number of collision shapes in this model.
 
const std::vector< std::shared_ptr< ChCollisionShape > > & GetShapes () const
 Get the list of collision shapes in this model.
 
std::shared_ptr< ChCollisionShapeGetShape (int index)
 Get the collision shape with specified index.
 
virtual ChCoordsys GetShapePos (int index) const =0
 Return the position and orientation of the collision shape with specified index, relative to the model frame.
 
virtual std::vector< double > GetShapeDimensions (int index) const =0
 Return shape characteristic dimensions. More...
 
void SetShapeMaterial (int index, std::shared_ptr< ChMaterialSurface > mat)
 Set the contact material for the collision shape with specified index.
 
void SetAllShapesMaterial (std::shared_ptr< ChMaterialSurface > mat)
 Set the contact material for all collision shapes in the model (all shapes will share the material). More...
 

Static Public Member Functions

static void SetDefaultSuggestedEnvelope (double menv)
 Using this function BEFORE you start creating collision shapes, it will make all following collision shapes to take this collision envelope (safe outward layer) as default. More...
 
static void SetDefaultSuggestedMargin (double mmargin)
 Using this function BEFORE you start creating collision shapes, it will make all following collision shapes to take this collision margin (inward penetration layer) as default. More...
 
static double GetDefaultSuggestedEnvelope ()
 
static double GetDefaultSuggestedMargin ()
 

Protected Member Functions

void CopyShapes (ChCollisionModel *other)
 Copy the collision shapes from another model.
 
virtual float GetSuggestedFullMargin ()
 

Protected Attributes

float model_envelope
 Maximum envelope: surrounding volume from surface to the exterior.
 
float model_safe_margin
 Maximum margin value to be used for fast penetration contact detection.
 
ChContactablemcontactable
 Pointer to the contactable object.
 
short int family_group
 Collision family group.
 
short int family_mask
 Collision family mask.
 
std::vector< std::shared_ptr< ChCollisionShape > > m_shapes
 list of collision shapes in model
 

Member Function Documentation

◆ Add2Dpath()

virtual bool chrono::collision::ChCollisionModel::Add2Dpath ( std::shared_ptr< ChMaterialSurface material,
std::shared_ptr< geometry::ChLinePath mpath,
const ChVector<> &  pos = ChVector<>(),
const ChMatrix33<> &  rot = ChMatrix33<>(1),
const double  thickness = 0.001 
)
inlinevirtual

Add a 2D closed line, defined on the XY plane passing by pos and aligned as rot, that defines a 2D collision shape that will collide with another 2D line of the same type if aligned on the same plane.

This is useful for mechanisms that work on a plane, and that require more precise collision that is not possible with current 3D shapes. For example, the line can contain concave or convex round fillets. Requirements:

  • the line must be clockwise for inner material, (counterclockwise=hollow, material outside)
  • the line must contain only ChLineSegment and ChLineArc sub-lines
  • the sublines must follow in the proper order, with coincident corners, and must be closed.
Parameters
materialsurface contact material
mpath2D curve path
posorigin position in model coordinates
rotrotation in model coordinates
thicknessline thickness

Reimplemented in chrono::collision::ChCollisionModelBullet.

◆ AddBarrel()

virtual bool chrono::collision::ChCollisionModel::AddBarrel ( std::shared_ptr< ChMaterialSurface material,
double  Y_low,
double  Y_high,
double  R_vert,
double  R_hor,
double  R_offset,
const ChVector<> &  pos = ChVector<>(),
const ChMatrix33<> &  rot = ChMatrix33<>(1) 
)
pure virtual

Add a barrel-like shape to this collision model (main axis on Y direction).

The barrel shape is made by lathing an arc of an ellipse around the vertical Y axis. The center of the ellipse is on Y=0 level, and it is offsetted by R_offset from the Y axis in radial direction. The two radii of the ellipse are R_vert (for the vertical direction, i.e. the axis parallel to Y) and R_hor (for the axis that is perpendicular to Y). Also, the solid is clamped with two discs on the top and the bottom, at levels Y_low and Y_high.

Parameters
materialsurface contact material
Y_lowbottom level
Y_hightop level
R_vertellipse semi-axis in vertical direction
R_horellipse semi-axis in horizontal direction
R_offsetlateral offset (radius at top and bottom)
poscenter position in model coordinates
rotrotation in model coordinates

Implemented in chrono::collision::ChCollisionModelBullet, and chrono::collision::ChCollisionModelChrono.

◆ AddBox()

virtual bool chrono::collision::ChCollisionModel::AddBox ( std::shared_ptr< ChMaterialSurface material,
double  hx,
double  hy,
double  hz,
const ChVector<> &  pos = ChVector<>(),
const ChMatrix33<> &  rot = ChMatrix33<>(1) 
)
pure virtual

Add a box shape to this collision model.

Parameters
materialsurface contact material
hxx half-dimension
hyy half-dimension
hzz half-dimension
poscenter position in model coordinates
rotrotation in model coordinates

Implemented in chrono::collision::ChCollisionModelBullet, chrono::collision::ChCollisionModelChrono, and chrono::collision::ChCollisionModelDistributed.

◆ AddCapsule()

virtual bool chrono::collision::ChCollisionModel::AddCapsule ( std::shared_ptr< ChMaterialSurface material,
double  radius,
double  hlen,
const ChVector<> &  pos = ChVector<>(),
const ChMatrix33<> &  rot = ChMatrix33<>(1) 
)
pure virtual

Add a capsule to this collision model (default axis in Y direction).

Parameters
materialsurface contact material
radiusradius
hlenhalf-length of capsule axis
poscenter position in model coordinates
rotrotation in model coordinates

Implemented in chrono::collision::ChCollisionModelChrono, and chrono::collision::ChCollisionModelBullet.

◆ AddCone()

virtual bool chrono::collision::ChCollisionModel::AddCone ( std::shared_ptr< ChMaterialSurface material,
double  rx,
double  rz,
double  hy,
const ChVector<> &  pos = ChVector<>(),
const ChMatrix33<> &  rot = ChMatrix33<>(1) 
)
pure virtual

Add a cone to this collision model (default axis on Y direction).

Parameters
materialsurface contact material
rxradius (X direction)
rzradius (Z direction)
hyhalf length
poscenter position in model coordinates
rotrotation in model coordinates

Implemented in chrono::collision::ChCollisionModelChrono, and chrono::collision::ChCollisionModelBullet.

◆ AddConvexHull()

virtual bool chrono::collision::ChCollisionModel::AddConvexHull ( std::shared_ptr< ChMaterialSurface material,
const std::vector< ChVector< double >> &  pointlist,
const ChVector<> &  pos = ChVector<>(),
const ChMatrix33<> &  rot = ChMatrix33<>(1) 
)
pure virtual

Add a convex hull to this collision model.

A convex hull is simply a point cloud that describe a convex polytope. Connectivity between the vertexes, as faces/edges in triangle meshes is not necessary. Points are passed as a list which is then copied into the model.

Parameters
materialsurface contact material
pointlistlist of hull points
posorigin position in model coordinates
rotrotation in model coordinates

Implemented in chrono::collision::ChCollisionModelBullet, and chrono::collision::ChCollisionModelChrono.

◆ AddConvexHullsFromFile()

bool chrono::collision::ChCollisionModel::AddConvexHullsFromFile ( std::shared_ptr< ChMaterialSurface material,
ChStreamInAscii mstream,
const ChVector<> &  pos = ChVector<>(),
const ChMatrix33<> &  rot = ChMatrix33<>(1) 
)
virtual

Add a cluster of convex hulls specified in a '.chulls' file description.

The file is an ascii text that contains lines with "[x] [y] [z]" coordinates of the convex hulls. Hulls are separated by lines with "hull". Inherited classes should not need to implement/overload this, because this base implementation basically calls AddConvexHull() n times while parsing the file, that is enough.

Parameters
materialsurface contact material
mstreaminput data file
posorigin position in model coordinates
rotrotation in model coordinates

◆ AddCopyOfAnotherModel()

virtual bool chrono::collision::ChCollisionModel::AddCopyOfAnotherModel ( ChCollisionModel another)
pure virtual

Add all shapes already contained in another model.

If possible, derived classes should implement this so that underlying shapes are shared (not copied) among the models.

Implemented in chrono::collision::ChCollisionModelBullet, and chrono::collision::ChCollisionModelChrono.

◆ AddCylinder()

virtual bool chrono::collision::ChCollisionModel::AddCylinder ( std::shared_ptr< ChMaterialSurface material,
double  rx,
double  rz,
double  hy,
const ChVector<> &  pos = ChVector<>(),
const ChMatrix33<> &  rot = ChMatrix33<>(1) 
)
pure virtual

Add a cylinder to this collision model (default axis in Y direction).

Parameters
materialsurface contact material
rxradius (X direction)
rzradius (Z direction)
hyhalf length
poscenter position in model coordinates
rotrotation in model coordinates

Implemented in chrono::collision::ChCollisionModelChrono, and chrono::collision::ChCollisionModelBullet.

◆ AddCylindricalShell()

virtual bool chrono::collision::ChCollisionModel::AddCylindricalShell ( std::shared_ptr< ChMaterialSurface material,
double  radius,
double  hlen,
const ChVector<> &  pos = ChVector<>(),
const ChMatrix33<> &  rot = ChMatrix33<>(1) 
)
pure virtual

Add a cylindrical shell to this collision model (default axis in Y direction).

Parameters
materialsurface contact material
radiuscylinder radius
hlencylinder half length
poscenter position in model coordinates
rotrotation in model coordinates

Implemented in chrono::collision::ChCollisionModelChrono, and chrono::collision::ChCollisionModelBullet.

◆ AddEllipsoid()

virtual bool chrono::collision::ChCollisionModel::AddEllipsoid ( std::shared_ptr< ChMaterialSurface material,
double  rx,
double  ry,
double  rz,
const ChVector<> &  pos = ChVector<>(),
const ChMatrix33<> &  rot = ChMatrix33<>(1) 
)
pure virtual

Add an ellipsoid shape to this collision model.

Parameters
materialsurface contact material
rxx semi-axis
ryy semi-axis
rzz semi-axis
poscenter position in model coordinates
rotrotation in model coordinates

Implemented in chrono::collision::ChCollisionModelBullet, and chrono::collision::ChCollisionModelChrono.

◆ AddPoint()

virtual bool chrono::collision::ChCollisionModel::AddPoint ( std::shared_ptr< ChMaterialSurface material,
double  radius = 0,
const ChVector<> &  pos = ChVector<>() 
)
inlinevirtual

Add a point-like sphere, that will collide with other geometries, but won't ever create contacts between them.

Parameters
materialsurface contact material
radiusnode radius
poscenter position in model coordinates

Reimplemented in chrono::collision::ChCollisionModelBullet.

◆ AddRoundedBox()

virtual bool chrono::collision::ChCollisionModel::AddRoundedBox ( std::shared_ptr< ChMaterialSurface material,
double  hx,
double  hy,
double  hz,
double  sphere_r,
const ChVector<> &  pos = ChVector<>(),
const ChMatrix33<> &  rot = ChMatrix33<>(1) 
)
pure virtual

Add a rounded box shape to this collision model.

Parameters
materialsurface contact material
hxx half-dimension
hyy half-dimension
hzz half-dimension
sphere_rradius of sweeping sphere
poscenter position in model coordinates
rotrotation in model coordinates

Implemented in chrono::collision::ChCollisionModelBullet, and chrono::collision::ChCollisionModelChrono.

◆ AddRoundedCone()

virtual bool chrono::collision::ChCollisionModel::AddRoundedCone ( std::shared_ptr< ChMaterialSurface material,
double  rx,
double  rz,
double  hy,
double  sphere_r,
const ChVector<> &  pos = ChVector<>(),
const ChMatrix33<> &  rot = ChMatrix33<>(1) 
)
pure virtual

Add a rounded cone to this collision model (default axis on Y direction).

Parameters
materialsurface contact material
rxradius (X direction)
rzradius (Z direction)
hyhalf length
sphere_rradius of sweeping sphere
poscenter position in model coordinates
rotrotation in model coordinates

Implemented in chrono::collision::ChCollisionModelBullet, and chrono::collision::ChCollisionModelChrono.

◆ AddRoundedCylinder()

virtual bool chrono::collision::ChCollisionModel::AddRoundedCylinder ( std::shared_ptr< ChMaterialSurface material,
double  rx,
double  rz,
double  hy,
double  sphere_r,
const ChVector<> &  pos = ChVector<>(),
const ChMatrix33<> &  rot = ChMatrix33<>(1) 
)
pure virtual

Add a rounded cylinder to this collision model (default axis on Y direction).

Parameters
materialsurface contact material
rxradius (X direction)
rzradius (Z direction)
hyhalf length
sphere_rradius of sweeping sphere
poscenter position in model coordinates
rotrotation in model coordinates

Implemented in chrono::collision::ChCollisionModelBullet, and chrono::collision::ChCollisionModelChrono.

◆ AddSphere()

virtual bool chrono::collision::ChCollisionModel::AddSphere ( std::shared_ptr< ChMaterialSurface material,
double  radius,
const ChVector<> &  pos = ChVector<>() 
)
pure virtual

Add a sphere shape to this collision model.

Parameters
materialsurface contact material
radiussphere radius
poscenter position in model coordinates

Implemented in chrono::collision::ChCollisionModelBullet, chrono::collision::ChCollisionModelChrono, and chrono::collision::ChCollisionModelDistributed.

◆ AddTriangleMesh()

virtual bool chrono::collision::ChCollisionModel::AddTriangleMesh ( std::shared_ptr< ChMaterialSurface material,
std::shared_ptr< geometry::ChTriangleMesh trimesh,
bool  is_static,
bool  is_convex,
const ChVector<> &  pos = ChVector<>(),
const ChMatrix33<> &  rot = ChMatrix33<>(1),
double  sphereswept_thickness = 0.0 
)
pure virtual

Add a triangle mesh to this collision model.

Note: if possible, for better performance, avoid triangle meshes and prefer simplified representations as compounds of primitive convex shapes (boxes, sphers, etc).

Parameters
materialsurface contact material
trimeshthe triangle mesh
is_statictrue if model doesn't move. May improve performance.
is_convexif true, a convex hull is used. May improve robustness.
posorigin position in model coordinates
rotrotation in model coordinates
sphereswept_thicknessoutward sphere-swept layer (when supported)

Implemented in chrono::collision::ChCollisionModelBullet, and chrono::collision::ChCollisionModelChrono.

◆ BuildModel()

virtual int chrono::collision::ChCollisionModel::BuildModel ( )
pure virtual

Complete the construction of the collision model.

Addition of collision shapes must be done between calls to ClearModel() and BuildModel(). This function must be invoked after all geometric collision shapes have been added.

Implemented in chrono::collision::ChCollisionModelBullet, and chrono::collision::ChCollisionModelChrono.

◆ ClearModel()

virtual int chrono::collision::ChCollisionModel::ClearModel ( )
pure virtual

Delete all inserted geometries.

Addition of collision shapes must be done between calls to ClearModel() and BuildModel(). This function must be invoked before adding geometric collision shapes.

Implemented in chrono::collision::ChCollisionModelBullet, chrono::collision::ChCollisionModelChrono, and chrono::collision::ChCollisionModelDistributed.

◆ GetAABB()

virtual void chrono::collision::ChCollisionModel::GetAABB ( ChVector<> &  bbmin,
ChVector<> &  bbmax 
) const
pure virtual

Return the axis aligned bounding box (AABB) of the collision model, i.e.

max-min along the x,y,z world axes. Remember that SyncPosition() should be invoked before calling this.

Implemented in chrono::collision::ChCollisionModelBullet, chrono::collision::ChCollisionModelChrono, and chrono::collision::ChCollisionModelDistributed.

◆ GetFamilyGroup()

virtual short int chrono::collision::ChCollisionModel::GetFamilyGroup ( ) const
inlinevirtual

Return the collision family group of this model.

The collision family of this model is the position of the single set bit in the return value.

◆ GetFamilyMask()

virtual short int chrono::collision::ChCollisionModel::GetFamilyMask ( ) const
inlinevirtual

Return the collision mask for this model.

Each bit of the return value indicates whether this model collides with the corresponding family (bit set) or not (bit unset).

◆ GetFamilyMaskDoesCollisionWithFamily()

bool chrono::collision::ChCollisionModel::GetFamilyMaskDoesCollisionWithFamily ( int  mfamily)
virtual

Tells if the family mask of this collision object allows for the collision with another collision object belonging to a given family.

This default implementation uses the family mask.

Reimplemented in chrono::collision::ChCollisionModelBullet.

◆ GetPhysicsItem()

ChPhysicsItem * chrono::collision::ChCollisionModel::GetPhysicsItem ( )
virtual

Get the pointer to the client owner ChPhysicsItem.

Default: just casts GetContactable(). Just for backward compatibility. It might return null if contactable not inherited by ChPhysicsItem. TODO remove the need of ChPhysicsItem*, just use ChContactable* in all code

◆ GetShapeDimensions()

virtual std::vector<double> chrono::collision::ChCollisionModel::GetShapeDimensions ( int  index) const
pure virtual

Return shape characteristic dimensions.

A derived class should implement this function for as many of the following shapes as possible.

SPHERE       radius
BOX          x-halfdim y-halfdim z-halfdim
ELLIPSOID    x-radius y-radius z-radius
CYLINDER     x-radius z-radius halflength
CONE         x-radius z-radius halfheight
CAPSULE      radius halflength
ROUNDEDBOX   x-halfdim y-halfdim z-halfdim sphere_rad
ROUNDEDCYL   x-radius z-radius halflength sphere_rad

Implemented in chrono::collision::ChCollisionModelBullet, and chrono::collision::ChCollisionModelChrono.

◆ SetAllShapesMaterial()

void chrono::collision::ChCollisionModel::SetAllShapesMaterial ( std::shared_ptr< ChMaterialSurface mat)

Set the contact material for all collision shapes in the model (all shapes will share the material).

This function is useful in adjusting contact material properties for objects imported from outside (e.g., from SolidWorks).

◆ SetContactable()

virtual void chrono::collision::ChCollisionModel::SetContactable ( ChContactable mc)
inlinevirtual

Set the pointer to the contactable object.

A derived class may override this, but should always invoke this base class implementation.

Reimplemented in chrono::collision::ChCollisionModelChrono.

◆ SetDefaultSuggestedEnvelope()

void chrono::collision::ChCollisionModel::SetDefaultSuggestedEnvelope ( double  menv)
static

Using this function BEFORE you start creating collision shapes, it will make all following collision shapes to take this collision envelope (safe outward layer) as default.

Easier than calling SetEnvelope() all the times.

◆ SetDefaultSuggestedMargin()

void chrono::collision::ChCollisionModel::SetDefaultSuggestedMargin ( double  mmargin)
static

Using this function BEFORE you start creating collision shapes, it will make all following collision shapes to take this collision margin (inward penetration layer) as default.

If you call it again later, it will have no effect, except for shapes created later. Easier than calling SetMargin() all the times.

◆ SetEnvelope()

virtual void chrono::collision::ChCollisionModel::SetEnvelope ( double  amargin)
inlinevirtual

Set the suggested collision outward 'envelope' (used from shapes added, from now on, to this collision model).

This 'envelope' is a surrounding invisible volume which extends outward from the surface, and it is used to detect contacts a bit before shapes come into contact, i.e. when dist>0. However contact points will stay on the true surface of the geometry, not on the external surface of the envelope. Call this BEFORE adding the shapes into the model. Side effect: AABB are 'expanded' outward by this amount, so if you exaggerate with this value, CD might be slower and too sensible. On the other hand, if you set this value to 0, contacts are detected only for dist<=0, thus causing unstable simulation.

◆ SetFamily()

void chrono::collision::ChCollisionModel::SetFamily ( int  mfamily)
virtual

By default, all collision objects belong to family n.0, but you can set family in range 0..15.

This is used when the objects collided with another: the contact is created only if the family is within the 'family mask' of the other, and viceversa. These default implementations use the family group.

Reimplemented in chrono::collision::ChCollisionModelBullet.

◆ SetFamilyGroup()

void chrono::collision::ChCollisionModel::SetFamilyGroup ( short int  group)
virtual

Set the collision family group of this model.

This is an alternative way of specifying the collision family for this object. The value family_group must have a single bit set (i.e. it must be a power of 2). The corresponding family is then the bit position.

Reimplemented in chrono::collision::ChCollisionModelBullet.

◆ SetFamilyMask()

void chrono::collision::ChCollisionModel::SetFamilyMask ( short int  mask)
virtual

Set the collision mask for this model.

Any set bit in the specified mask indicates that this model collides with all objects whose family is equal to the bit position.

Reimplemented in chrono::collision::ChCollisionModelBullet.

◆ SetFamilyMaskNoCollisionWithFamily()

void chrono::collision::ChCollisionModel::SetFamilyMaskNoCollisionWithFamily ( int  mfamily)
virtual

By default, family mask is all turned on, so all families can collide with this object, but you can turn on-off some bytes of this mask so that some families do not collide.

When two objects collide, the contact is created only if the family is within the 'family mask' of the other, and viceversa. These default implementations use the family mask.

Reimplemented in chrono::collision::ChCollisionModelBullet.

◆ SetSafeMargin()

virtual void chrono::collision::ChCollisionModel::SetSafeMargin ( double  amargin)
inlinevirtual

Set the suggested collision 'inward safe margin' for the shapes to be added from now on, using the AddBox, AddCylinder etc (where, if this margin is too high for some thin or small shapes, it may be clamped).

If dist<0 and interpretation occurs (ex.for numerical errors) within this 'safe margin' inward range, collision detection is still fast and reliable (beyond this, for deep penetrations, CD still works, but might be slower and less reliable) Call this BEFORE adding the shapes into the model. Side effect: think at the margin as a radius of a 'smoothing' fillet on all corners of the shapes - that's why you cannot exceed with this.


The documentation for this class was generated from the following files:
  • /builds/uwsbel/chrono/src/chrono/collision/ChCollisionModel.h
  • /builds/uwsbel/chrono/src/chrono/collision/ChCollisionModel.cpp