NX二次开发 PK创建环(类似密封圈) PK_BODY_create_solid_torus
//创建环(类似密封圈)
bool PK_CreateTorus(const double point[3], const double dir[3], const double diam[2], PK_BODY_t& pkBody)
{
double d[2] = { 0.0 };
double mm = 0.001, mat_3d[9] = { 0.0 };
d[0] = fabs(diam[0]);
d[1] = fabs(diam[1]);
pkBody = PK_ENTITY_null;
if (d[0] < g_dist_tol || d[1] < g_dist_tol)
{
return false;
}
if (d[0] == d[1])
{
return PK_CreateSphere(point, d[0], pkBody);
}
if (diam[0] > diam[1])
{
d[0] = diam[1];
d[1] = diam[0];
}
if (UF_MTX3_initialize_z(dir, mat_3d))
return false;
PK_AXIS2_sf_t basis_set;
basis_set.location.coord[0] = point[0] * mm;
basis_set.location.coord[1] = point[1] * mm;
basis_set.location.coord[2] = point[2] * mm;
UF_MTX3_z_vec(mat_3d, basis_set.axis.coord);
UF_MTX3_x_vec(mat_3d, basis_set.ref_direction.coord);
PK_BODY_create_solid_torus(d[1] * 0.5 * mm, d[0] * 0.5 * mm, &basis_set, &pkBody);
if (PK_ENTITY_null == pkBody)
return false;
return true;
}