## Collision Detection Queries Sometimes, it is required not only to detect a collision of bodies, but also to get a list of colliding faces, as shown in Fig. R.4.2.2, or reveal groups of bodies, for which collision detection is not required. This is achieved using a set of type classes (cdet_query inheritors) configured to request collision details: - The cdet_query_result structure is the simplest and the quickest variant for detecting collisions in the body control group. This structure is used as a default parameter in the **CheckCollisions** method. - The cdet_first_collided structure gives the first found pair of colliding faces. - The cdet_collided_faces structure gives a set of colliding faces as an ordered set of pairs std::pair\, where the first element in the pair is a solid body model in the client application, and the second element in the pair is a face belonging to the model. The cdet_collided_faces::**Group**() method permits to group the objects of the control body set to detect only intersections between the groups. The cdet_collided_faces::**Group** method groups a pair of bodies; in order to join ***n*** bodies in a group, you should call the cdet_collided_faces::**Group**() method ***n***-1 times for the first body and all other bodies in the group. Item [Configuring a Collision Detection Query](./Configuring_a_Collision_Detection_Query.md) describes how the geometric kernel user can configure his/her own queries by using the cdet_query inheritance. However, in most cases you can simply use the cdet_collided_faces class for a query. To do this, please create cdet_collided_faces instance and use it as a parameter in **CheckCollisions** method. Before this, you can configure the detection filter using the cdet_collided_faces::**Group** and cdet_collided_faces::**ExcludeGroup** methods. If required, you can reset the search filter by calling the cdet_collided_faces::Reset method and reconfiguring the filter. The method ```cpp cdet_collided_faces::Group(cdet_app_item fst, cdet_app_item snd) ``` declares a group of bodies, the elements of which are not checked for collision with each other. The method input parameters are: *fst* and *snd* are a pair of bodies already included in the groups or grouped for the first time. This method groups two bodies or adds one body to the group of the other body. So, if you want to group ***n*** bodies, you need to call the cdet_collided_faces::Group method ***n***-1 times for the first body and for all other bodies in the group. The method ```cpp cdet_collided_faces::ExcludeGroup(cdet_app_item member) ``` excludes all group elements from the collision detection. The input parameter of the method is *member* -- any body in the group, the elements of which are excluded. This method disables all collision checks in this group. It is recommended to use this method to temporarily disable the body check collisions without complete deletion from the set using the MbCollisionDetectionUtility::**RemoveItem** method, because adding them later using **AddItem** method requires more computation time than cancelling the exclusion using the cdet_collided_faces::**Reset** method. There are two possible ways to exclude a body set from collision detection: either call the **ExcludeGroup** method many times for all set elements or first group all the bodies that should be excluded and then call the **ExcludeGroup** method once for any body included in the group. The method ```cpp cdet_collided_faces::Reset() ``` resets all the **Group** and **ExcludeGroup** call results. The method is used if it is required to reconfigure the groups and the exceptions for the previously defined cdet_collided_faces query structure.