|
马上注册登录,享用更多网站功能!
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
ZZZ和各位版主,各位学长 很不好意思现在还因为这么简单的问题打扰大家,但小弟试了很多次了就是得不到结果, 在建立好的模型上做条截面线,然后哦求得2截面线的交点,截面线我做出来了 但交点始终得不到 ,请ZZZ大哥和其他各位学长帮我看看,感激不尽
void ufusr(char *param, int *retcode, int param_len)
{
if (!UF_CALL(UF_initialize()))
{
//////////////////////////////////////////////////////////获得当前叶object_id
int type1,subtype;
tag_t part_tag;
tag_t block_tag;
tag_t plane1_tag;
part_tag=UF_PART_ask_display_part();
block_tag=NULL_TAG;
UF_OBJ_cycle_objs_in_part(part_tag,UF_solid_type,&block_tag);
while (block_tag)
{
UF_OBJ_ask_type_and_subtype(block_tag,&type1,&subtype);
if (subtype==UF_solid_body_subtype)
{
break;
}
UF_OBJ_cycle_objs_in_part(part_tag,UF_solid_type,&block_tag);
}
////////////////第一条截面线
double origin1_point[3];
double pl1_normal[3];
origin1_point[0] = 20.0;
origin1_point[1] = 40.0;
origin1_point[2] = 0;
pl1_normal[0] = 0.0;
pl1_normal[1] = 0.0;
pl1_normal[2] = 1.0;
UF_MODL_create_plane(origin1_point, pl1_normal, &plane1_tag);
tag_t objects1[1];
tag_t planes1[100];
objects1[0]=block_tag;
tag_t section_curves_feature1;
UF_CURVE_section_general_data_t general1_data;
UF_CURVE_section_planes_data_t planes1_data;
planes1[0] = plane1_tag;
general1_data.associate = 1;
general1_data.objects = objects1;
general1_data.num_objects = 1;
general1_data.grouping = 0;
general1_data.join_type = 0;
general1_data.tolerance = 0.0245;
planes1_data.planes = planes1;
planes1_data.num_planes = 1;
UF_CURVE_section_from_planes (&general1_data, &planes1_data,
§ion_curves_feature1);
double origin2_point[3];
double pl2_normal[3];
origin2_point[0] = 20.0;
origin2_point[1] = 0;
origin2_point[2] = 40.0;
pl2_normal[0] = 0.0;
pl2_normal[1] = 1.0;
pl2_normal[2] = 0.0;
//////////////////////第二截面线
tag_t plane2_tag;
UF_MODL_create_plane(origin2_point, pl2_normal, &plane2_tag);
tag_t objects2[1];
tag_t planes2[100];
objects2[0]=block_tag;
tag_t section_curves_feature2;
UF_CURVE_section_general_data_t general2_data;
UF_CURVE_section_planes_data_t planes2_data;
planes2[0] = plane2_tag;
general2_data.associate = 1;
general2_data.objects = objects2;
general2_data.num_objects = 1;
general2_data.grouping = 0;
general2_data.join_type = 0;
general2_data.tolerance = 0.0245;
planes2_data.planes = planes2;
planes2_data.num_planes = 1;
UF_CURVE_section_from_planes (&general2_data, &planes2_data,
§ion_curves_feature2);
////////////////////求交
int num_intersects, type;
UF_MODL_intersect_info_p_t *intersect_data;
double tol = 0.1;
UF_MODL_intersect_objects(section_curves_feature2,section_curves_feature1,
tol,&num_intersects,&intersect_data);
红色部分是不是有错误?
FILE *fp4;
if((fp4=fopen("e:\\my_source\\line4.txt","w"))==NULL)
{
printf("could not open data file.");
exit(0);
}
int i;
for(i = 0; i < num_intersects; i++)
{
type = (intersect_data)->intersect_type;
switch(type)
{
case UF_MODL_INTERSECT_POINT:
fprintf(fp4,"\nx,y,z coordinates are: (%f, %f, %f)\n",
(intersect_data)->intersect.point.coords[0],
(intersect_data)->intersect.point.coords[1],
(intersect_data)->intersect.point.coords[2]);
fprintf(fp4,"Object 1 UV parameters are: (%f, %f)\n",
(intersect_data)->intersect.point.object_1_u_parm,
(intersect_data)->intersect.point.object_1_v_parm);
fprintf(fp4,"Object 2 UV parameters are: (%f, %f)\n",
(intersect_data)->intersect.point.object_2_u_parm,
(intersect_data)->intersect.point.object_2_v_parm);
break;
case UF_MODL_INTERSECT_COINCIDE:
printf("\nCoincident curve tag is: %d\n",
intersect_data->intersect.coincide.identifier);
printf("Object 1 UV parameters are: (%f, %f)\n",
intersect_data->intersect.coincide.object_1_first_parm,
intersect_data->intersect.coincide.object_1_second_parm);
printf("Object 2 UV parameters are: (%f, %f)\n",
intersect_data->intersect.coincide.object_2_first_parm,
intersect_data->intersect.coincide.object_2_second_parm);
break;
case UF_MODL_INTERSECT_CURVE:
printf("\nThe curve identifier is: %d\n",
(intersect_data)->intersect.curve.identifier);
break;
default:
printf("\nSomething went wrong, we shouldn't be here!");
break;
}
// Free each element of the array.
UF_free(intersect_data);
}
if(num_intersects != 0)
{
//// Free the array.
UF_free(intersect_data);
}
UF_CALL(UF_terminate());
}
}
int ufusr_ask_unload(void)
{
return (UF_UNLOAD_IMMEDIATELY);
} |
-
1.jpg
(15.59 KB, 下载次数: 4)
图
|