hm_collisiongetcomponententitypair

Returns the entity details for an entity collision pair.

Syntax

hm_collisiongetcomponententitypair collision_type component_index entity_index ?include_ignored?

Type

HyperMesh Tcl Query Command

Description

Returns the entity details for an entity collision pair. This must be preceded by a call to relevant hm_collision* commands to generate the collision data. In addition, the pair_results flag to hm_collisioncheck must be set to 1.

For intersections, this returns a list of values that contains:
  • entity_type1 entity_id1 face_index1 entity_type2 entity_id2 face_index2
For penetrations, this returns a list of values that contains:
  • entity_type1 entity_id1 face_index1 entity_type2 entity_id2 face_index2 depth direction_x direction_y directon_z
For each collision type there is a list of pairs of colliding components. For each colliding component pair, there is a list of colliding entity pairs. Thus, there is a hierarchy of data with the tree looking like this:
  • collision type -> component pairs -> entity pairs
The data is therefore accessed as:
  1. Get the number of colliding component pairs
  2. Get the component IDs for each component pair
  3. Get the number of intersected entities for each component pair
  4. Get the entity types, IDs, and faces (for intersections) or the entity types, IDs, faces, depths and directions (for penetrations) for each intersected entity pair.

Inputs

collision_type
The type of collision to query:
0 - intersections
1 - penetrations
component_index
The index of the component pair to query, starting from 0. The total number of component pairs for a specific collision_type can be found using hm_collisongetcomponentpaircount.
entity_index
The index of the entity pair to query, starting from 0. The total number of entity pairs for a specific component_index can be found using hm_collisongetcomponententitypaircount.
include_ignored (optional)
Specifies if results ignored when the allowable_depth value is specified via hm_collisioninit should be reported or not:
0 - Do not include ignored results (default).
1 - Include ignored results.

Examples

To find intersecting surfaces from IDs 1-10, and to get the detailed list of entities for each intersection:

*createmark surfs 1 1-10
hm_collisioninit
hm_collisionentitycreate surfs 1 0 1 0 0 0 0 0 0
hm_collisioncheck 0 0 1 0 0 0 0 90.0 0 0 0.0 1
set component_pair_count [hm_collisiongetcomponentpaircount 0]
if {$pair_count > 0} {
    for {set i 0} {$i < $component_pair_count} {incr i} {
        set component_pairs($i) [hm_collisiongetcomponentpair 0 $i]
        set entity_pair_count [hm_collisiongetcomponententitypaircount 0 $i]
        if {$pair_count != 0} {
            for {set j 0} {$j < $entity_pair_count} {incr j} {
                set entity_pairs($i,$j) [hm_collisiongetcomponententitypair 0 $i $j]
                lassign $entity_pairs($i,$j) type id1 dd1 type2 id2 dd2
            }
        }
    }
}
hm_collisionend

To find penetrating surfaces from IDs 1-10, using the thickness assigned to the surface components, and to get the detailed list of entities for each intersection:

*createmark surfs 1 1-10
hm_collisioninit
hm_collisionentitycreate surfs 1 0 1 0 0 0 0 0 0
hm_collisioncheck 0 0 0 1 0 0 0 90.0 0 0 0.0 1
set component_pair_count [hm_collisiongetcomponentpaircount 1]
if {$pair_count > 0} {
    for {set i 0} {$i < $component_pair_count} {incr i} {
        set component_pairs($i) [hm_collisiongetcomponentpair 1 $i]
        set entity_pair_count [hm_collisiongetcomponententitypaircount 1 $i]
        if {$pair_count != 0} {
            for {set j 0} {$j < $entity_pair_count} {incr j} {
                set entity_pairs($i,$j) [hm_collisiongetcomponententitypair 1 $i $j]
                lassign $entity_pairs($i,$j) type id1 dd1 type2 id2 dd2 depth x y z
            }
        }
    }
}
hm_collisionend

Errors

Incorrect usage results in a Tcl error. To detect errors, you can use the catch command:
if { [ catch {command_name...} ] } {
   # Handle error
}

Version History

13.0