hm_collisiongetcomponentlinesegment

Returns the start and end coordinates of intersection line segments.

Syntax

hm_collisiongetcomponentlinesegment component_index linesegment_index ?include_ignored?

Type

HyperMesh Tcl Query Command

Description

Returns the line segment coordinates for a component collision pair.

Once the call to the relevant hm_collision* commands to generate the collision data is made, this command can follow. In addition, the pair_results flag to hm_collisioncheck must be set to 1.

This returns a list of values that contains six coordinates: x_coordinate_start y_coordinate_start z_coordinate_start x_coordinate_end y_coordinate_end z_coordinate_end

For each intersecting type of collision, there is a list of pairs of intersecting components. For each intersecting component pair, there is a list of intersection line segments.

To execute this command, the below sequence of data collection is required:
  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

Inputs

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_collisiongetcomponentpaircount.
linesegment_index
The index of the the line segment to query, starting from 0. The total number of entity pairs for a specific component_index can be found using hm_collisiongetcomponentlinesegmentcount.
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 create nodes at the centerr of intersection line segments for intersecting comps with ID 1 and 2:

set compList1 1;
set compList2 2;
set entityType1 elems;
set entityType2 elems;

hm_collisioninit 0 1e-5 
hm_createmark $entityType1 1 "by comp id" $compList1;
hm_createmark $entityType2 2 "by comp id" $compList2;
hm_collisionentitycreate $entityType1 1 0 0 0.0 0 0 0 0 0;
hm_collisionentitycreate $entityType2 2 0 0 0.0 0 0 0 0 0;
hm_collisioncheck 0 0 1 0 0 0 0 90.0 1 0 0 1;
set component_pair_count [ hm_collisiongetcomponentpaircount 0 0 ];
if {$component_pair_count > 0} {
    for {set i 0} {$i < $component_pair_count} {incr i} {
        set linesegmentcount [hm_collisiongetcomponentlinesegmentcount $i]
        if {$linesegmentcount != 0} {
            for {set j 0} {$j < $linesegmentcount} {incr j} {
                set linesegments [hm_collisiongetcomponentlinesegment $i $j]
                set x_0 [lindex $linesegments 0]
                set y_0 [lindex $linesegments 1]
                set z_0 [lindex $linesegments 2]
                set x_1 [lindex $linesegments 3]
                set y_1 [lindex $linesegments 4]
                set z_1 [lindex $linesegments 5]
                set curr_x [expr { ($x_0 + $x_1)/2 }]
                set curr_y [expr { ($y_0 + $y_1)/2 }]
                set curr_z [expr { ($z_0 + $z_1)/2 }]
                *createnode $curr_x $curr_y $curr_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

2019