Determining Collisions in the Set of Bodies
This collision evaluation method is used when it is required to perform a series of collision tests for the same set of bodies that change their position in time. Fig. 1.2.1 shows a mechanism constituting an assembly unit with seven parts that have kinematic links. It is required to estimate the boundaries within which the parts do not interfere with each other when the mechanism works. Fig. 1.2.2 shows a position of mechanism parts when they collide. The faces of bodies that contacted each other when they moved beyond the free motion boundaries are colored red:
Fig. 1
Fig. 2
In order to control collisions for a specific set of bodies, it is required to create an instance of the MbCollisionDetectionUtility class, and add the bodies to the collision control set using the AddItem() method. At the moment when one or several bodies change their position, the application calls the Reposition method to provide new position to the bodies included in the set, and determines whether there is a collision in the geometric model by calling the CheckCollisions method.
The MbCollisionDetectionUtilit class controls collisions, it is declared in cdet_utility.h file. The additional data types are declared in cdet_data.h.
The method
cdet_item MbCollisionDetectionUtility::AddItem (const MbSolid & solid,
const MbPlacement3D & place,
cdet_app_item appItem = CDET_APP_NULL)
adds solid body to the collision control set.
The method input parameters are:
solid is a solid body model,
place is a local coordinate system, which determines the position of the solid body in space,
appItem is a client application geometric object containing the body.
The method returns a collision control object descriptor.
The appItem parameter is used to identify the client application model objects when they collide. If the appItem parameter is not defined, then identification is based only on cdet_item type descriptor that was used to register the body in the set. It is assumed that more than one MbSolid body can belong to one appItem object, i.e. the AddItem method can be called more than once for the same object with appItem parameter. In this case, the bodies from the group added for the same appItem parameter are not checked for collisions between them.
The method
cdet_item MbCollisionDetectionUtility::RemoveItem(cdet_item cdItem)
deletes a solid body from the collision control set.
The input parameter of the method is cdItem – a descriptor of the collision control object that was added earlier using AddItem() method.
The method returns the object descriptor.
The method
cdet_result MbCollisionDetectionUtility::CheckCollisions(cdet_query cdQuery = defaultQuery)
checks for collisions between the objects in the control body set.
The input parameter of the method is cdQuery – a collision data query structure.
The method returns the collision search result code, which may contain the following codes:
CDM_RESULT_None – result of undefined type;
CDM_RESULT_NoCollisionDetected – no collision was detected: there are no intersections or the search was aborted;
CDM_RESULT_CollisionDetected – volume intersection (collision) detected;
CDM_RESULT_Error – unknown error or internal system error.
The CheckCollisions() method detects collisions between the solids or meshes added to the control set by calling the AddItem() method. The method returns CDM_RESULT_CollisionDetected, if a collision is detected in this body set. If no collisions were detected, then the method returns CDM_RESULT_NoCollisionDetected. The cdet_result code is the main result of the CheckCollisions algorithm. However, the cdQuery structure permits to get more detailed data on collision detection results, and to limit or even interrupt the search when required. If the cdQuery parameter is not defined, then the detection algorithm does not lose its time on studying all collision details, rather it stops when the first pair of intersecting faces is found.
If two or more bodies have been added in the same cdet_app_item object, then the collision check is not executed in such group.