hm_collisiongetcomponentlinesegmentcount
Returns the number of line segment for the component collision pair.
Syntax
hm_collisiongetcomponentlinesegmentcount component_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.
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:
- Get the number of colliding component pairs
- Get the number of intersection line segments for each component pair
- Get the line segments for each intersected 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.
- include_ignored (optional)
- Specifies if results ignored when the allowable_depth value is specified via hm_collisioninit should be reported or not:
Examples
To create nodes at the center 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