lugan2
Mechanical
- Apr 10, 2013
- 42
HI all;
I tried to create two 3D objects using OPEN C UF function, one using the revolve operation and the other using extrude operation. And then subtract one with the other. This operation gives me segmentation fault. Does anyone know why? I tried union method(using UF_POSITIVE) and intersection method (using UF_UNSIGNED), these two operation work OK. Is there a bug in the subtraction method for UF? The codes are posted as below. (I tried to adjust the size and position of one object, it seems that when the two only intersect, but not one covers the other entirely, the subtraction works fine.)
Many thanks!
I tried to create two 3D objects using OPEN C UF function, one using the revolve operation and the other using extrude operation. And then subtract one with the other. This operation gives me segmentation fault. Does anyone know why? I tried union method(using UF_POSITIVE) and intersection method (using UF_UNSIGNED), these two operation work OK. Is there a bug in the subtraction method for UF? The codes are posted as below. (I tried to adjust the size and position of one object, it seems that when the two only intersect, but not one covers the other entirely, the subtraction works fine.)
Many thanks!
Code:
int main()
{
UF_initialize();
tag_t part;
int english_units = 2;
char *part_name = "arm";
UF_PART_new(part_name, english_units, &part);
{
//===================
double pt1[3]={0,2,0}; // square
double pt2[3]={0,0,0};
double pt3[3]={2,0,0};
double pt4[3]={2,2,0};
double dir1[3] = {0.0,1.0,0.0};
double ref_pt[3];
char *taper_angle = "0.0";
char *limit1[2] = {"-.2", "4.5"};
int i, count = 4;
tag_t objarray[4], wcs_tag, matrix_tag;
uf_list_p_t loop_list, features;
int obj_count;
tag_t generators[4], *objects;
char *body_limit[2] = {"0.0", "120.0"};
char *offsets[2] = {"0.0", "0.0" };
double origin[3] = {-2.0, 0.0, 0.0};
double direction[3] = {0.0, 1.0, 0.0};
UF_MODL_SWEEP_TRIM_object_p_t trim_data = NULL;
UF_FEATURE_SIGN boolean0 = UF_NULLSIGN; UF_FEATURE_SIGN boolean1 = UF_POSITIVE;
UF_FEATURE_SIGN boolean2 = UF_NEGATIVE;
UF_FEATURE_SIGN boolean3 = UF_UNSIGNED;
UF_CURVE_line_t line1, line2, line3, line4;
UF_CURVE_line_t line5, line6, line7, line8;
//====================== create object using extrude
double pt5[3]= {-1, 0., -1};
double pt6[3]= {-1, 0., -.5};
double pt7[3]= {2.5, 0., -.5};
double pt8[3]= {2.5, 0., -1};
line1.start_point[0] = pt5[0];
line1.start_point[1] = pt5[1];
line1.start_point[2] = pt5[2];
line1.end_point[0] = pt6[0];
line1.end_point[1] = pt6[1];
line1.end_point[2] = pt6[2];
line2.start_point[0] = pt6[0];
line2.start_point[1] = pt6[1];
line2.start_point[2] = pt6[2];
line2.end_point[0] = pt7[0];
line2.end_point[1] = pt7[1];
line2.end_point[2] = pt7[2];
line3.start_point[0] = pt7[0];
line3.start_point[1] = pt7[1];
line3.start_point[2] = pt7[2];
line3.end_point[0] = pt8[0];
line3.end_point[1] = pt8[1];
line3.end_point[2] = pt8[2];
line4.start_point[0] = pt8[0];
line4.start_point[1] = pt8[1];
line4.start_point[2] = pt8[2];
line4.end_point[0] = pt5[0];
line4.end_point[1] = pt5[1];
line4.end_point[2] = pt5[2];
UF_CURVE_create_line(&line1,&objarray[0]);
UF_CURVE_create_line(&line2,&objarray[1]);
UF_CURVE_create_line(&line3,&objarray[2]);
UF_CURVE_create_line(&line4,&objarray[3]);
UF_MODL_create_list(&loop_list);
for(i = 0; i < count; i++)
{
UF_MODL_put_list_item(loop_list, objarray[i]);
}
//UF_MODL_create_extruded(loop_list, taper_angle, limit1, ref_pt, dir1, boolean0, &features);// this is for union, correct
UF_MODL_create_extruded(loop_list, taper_angle, limit1, ref_pt, dir1, boolean0, &features);// this is for union, correct
//UF_MODL_create_extruded(loop_list, taper_angle, limit1, ref_pt, dir1, boolean2, &features);
//UF_MODL_create_extruded(loop_list, taper_angle, limit1, ref_pt, dir1, boolean3, &features);
UF_PART_save();
//====================== create object using revolve
line5.start_point[0] = pt1[0];
line5.start_point[1] = pt1[1];
line5.start_point[2] = pt1[2];
line5.end_point[0] = pt2[0];
line5.end_point[1] = pt2[1];
line5.end_point[2] = pt2[2];
line6.start_point[0] = pt2[0];
line6.start_point[1] = pt2[1];
line6.start_point[2] = pt2[2];
line6.end_point[0] = pt3[0];
line6.end_point[1] = pt3[1];
line6.end_point[2] = pt3[2];
line7.start_point[0] = pt3[0];
line7.start_point[1] = pt3[1];
line7.start_point[2] = pt3[2];
line7.end_point[0] = pt4[0];
line7.end_point[1] = pt4[1];
line7.end_point[2] = pt4[2];
line8.start_point[0] = pt4[0];
line8.start_point[1] = pt4[1];
line8.start_point[2] = pt4[2];
line8.end_point[0] = pt1[0];
line8.end_point[1] = pt1[1];
line8.end_point[2] = pt1[2];
UF_CURVE_create_line(&line5,&objarray[0]);
UF_CURVE_create_line(&line6,&objarray[1]);
UF_CURVE_create_line(&line7,&objarray[2]);
UF_CURVE_create_line(&line8,&objarray[3]);
UF_MODL_create_list(&loop_list);
for(i = 0; i < count; i++)
{
UF_MODL_put_list_item(loop_list, objarray[i]);
}
//UF_MODL_create_revolved(loop_list, body_limit, origin, direction, boolean0, &features); //union is ok
UF_MODL_create_revolved(loop_list, body_limit, origin, direction, boolean1, &features);
// UF_MODL_create_revolved(loop_list, body_limit, origin, direction, boolean2, &features);
UF_PART_save();
}
UF_terminate();
}