Object 1
|
Object 2
|
Intersection Information
|
Point
|
Point, Curve, Edge, Datum Axis, Plane, Datum Plane,
Face
|
Point Information
|
Curve, Edge,
Datum Axis
|
Curve, Edge, Datum Axis, Plane, Datum Plane, Face
|
Point Information,
A coincident curve
|
Plane,
Datum Plane,
Face
|
Plane, Datum Plane, Face
|
Point Information,
An intersection curve
|
Body
|
Plane, Datum Plane, Face
|
An intersection curve
|
Field
|
Description
|
intersect_type
|
indication of type of intersection that occurred,
either a intersection point, a coincident curve, or a intersection curve.
This is set to one of the following values:
UF_MODL_INTERSECT_POINT
UF_MODL_INTERSECT_COINCIDE UF_MODL_INTERSECT_CURVE |
point
|
Information used to describe the intersection if
intersection_type = UF_MODL_INTERSECT_POINT, note that the parameter values
are defined only as specified below, otherwise they are set to 0. The parameter
values for the edge correspond to a curve that can be created from the
edge using UF_MODL_create_curve_from_edge.
coords[3] absolute coordinates of the intersection point
object_1_u_parm U parameter value of the intersection on object 1 if object 1 is a curve, edge or face. object_1_v_parm V parameter value of the intersection on object 1 if object 1 is a face. object_2_u_parm U parameter value of the intersection on object 2 if object 2 is a curve, edge or face. object_2_v_parm V parameter value of the intersection on object 2 if object 2 is a face. |
coincide
|
Information used to describe the intersection if
intersection_type = UF_MODL_COINCIDENT_CURVE, note that the parameter values
are defined only when the object is a curve or edge, otherwise they are
set to 0. The parameter values for the edge correspond to a curve that
can be created from the edge using UF_MODL_create_curve_from_edge.
identifier - the identifier of a curve that was created at
the coincidence of the two objects, the caller is responsible for deleting this curve. object_1_first_parm parameter value of the start of the coincident curve on object 1. object_1_second_parm parameter value of the end of the coincident curve on object 1. object_2_first_parm parameter value of the start of the coincident curve on object 2. object_2_second_parm parameter value of the end of the coincident curve on object 2. |
curve
|
Information used to describe the intersection if
intersection_type = UF_MODL_INTERSECT_CURVE:
identifier - the identifier of a curve that was created at
the intersection of the two objects, the caller is responsible for deleting this curve. |
#include <stdio.h> #include <uf_modl.h> #include <uf.h> #include <uf_obj.h> #include <uf_curve.h> #include <uf_defs.h> #include <uf_csys.h>
#define UF_CALL(X) (report( __FILE__, __LINE__, #X, (X)))
static void get_intersect(tag_t curve, tag_t face, double tol);
static int report( char *file, int line, char *call, int irc) { if (irc) { char messg[133]; printf("%s, line %d: %s\n", file, line, call); (UF_get_fail_message(irc, messg)) ? printf(" returned a %d\n", irc) : printf(" returned error %d: %s\n", irc, messg); } return(irc); }
static void do_ugopen_api(void) { tag_t base_sheet_id, line_id; tag_t face, arc_tag, line2_id; int num_pole_u = 4; int num_pole_v = 4; int u_ord = 4; int v_ord = 4; int knot_fix; int pole_fix; int i, j, k = 0;
UF_CURVE_line_t line_coords = {1.5,1.5,-2,1.5,1.5,1.0}; UF_CURVE_line_t line_coords2 = {0.0, 3.0, 0.0}; UF_CURVE_arc_t arc_coords = {NULL_TAG,0.0,180*DEGRA,1.5,0.0,-1.5,0.25}; uf_list_p_t list; double weight = 1.0; double u_knot[9] = {0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0}; double v_knot[9] = {0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0}; double pole[64]; double tol = .001; double matrix_values[9] = {1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0}; /* Create pole array data. */ for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { pole[k++] = i; pole[k++] = j; pole[k++] = 0.0; pole[k++] = weight; } }
/* Create base surface. */ UF_CALL(UF_MODL_create_bsurf(num_pole_u, num_pole_v, u_ord, v_ord, u_knot, v_knot,pole,&base_sheet_id, &knot_fix,&pole_fix)); /* Get faces. */ UF_CALL(UF_MODL_ask_body_faces(base_sheet_id,&list)); UF_CALL(UF_MODL_ask_list_item(list,0,&face)); UF_CALL(UF_MODL_delete_list(&list)); /* Create line. */ UF_CALL(UF_CURVE_create_line(&line_coords,&line_id)); /* Get line intersection. */ get_intersect(line_id, face, tol); /* Create coincident line. */ UF_CALL(UF_CURVE_create_line(&line_coords2,&line2_id)); UF_CALL(UF_OBJ_set_color(line2_id, UF_OBJ_YELLOW)); /* Get coincident line intersection data */ get_intersect(line2_id, face, tol); /* Create arc. */ UF_CALL(UF_CSYS_create_matrix(matrix_values,&arc_coords.matrix_tag)); UF_CALL(UF_CURVE_create_arc(&arc_coords, &arc_tag)); /* Get arc intersection. */ get_intersect(arc_tag, face, tol); }
/*ARGSUSED*/ void ufusr(char *param, int *retcode, int param_len) { if (!UF_CALL(UF_initialize())) { do_ugopen_api(); UF_CALL(UF_terminate()); } }
int ufusr_ask_unload(void) { return (UF_UNLOAD_IMMEDIATELY); }
static void get_intersect(tag_t curve, tag_t face, double tol) { int num_intersects, type, i; UF_MODL_intersect_info_p_t *intersect_data; UF_CALL(UF_MODL_intersect_objects(curve,face,tol,&num_intersects,&intersect_data)); printf("\n Number of intersections = %d\n", num_intersects); for(i = 0; i < num_intersects; i++) { type = (intersect_data[i])->intersect_type; switch(type) { case UF_MODL_INTERSECT_POINT: printf("\nx,y,z coordinates are: (%f, %f, %f)\n", (intersect_data[i])->intersect.point.coords[0], (intersect_data[i])->intersect.point.coords[1], (intersect_data[i])->intersect.point.coords[2]); printf("Object 1 UV parameters are: (%f, %f)\n", (intersect_data[i])->intersect.point.object_1_u_parm, (intersect_data[i])->intersect.point.object_1_v_parm); printf("Object 2 UV parameters are: (%f, %f)\n", (intersect_data[i])->intersect.point.object_2_u_parm, (intersect_data[i])->intersect.point.object_2_v_parm); break; case UF_MODL_INTERSECT_COINCIDE: printf("\nCoincident curve tag is: %d\n", intersect_data[i]->intersect.coincide.identifier); printf("Object 1 UV parameters are: (%f, %f)\n", intersect_data[i]->intersect.coincide.object_1_first_parm, intersect_data[i]->intersect.coincide.object_1_second_parm); printf("Object 2 UV parameters are: (%f, %f)\n", intersect_data[i]->intersect.coincide.object_2_first_parm, intersect_data[i]->intersect.coincide.object_2_second_parm); break; case UF_MODL_INTERSECT_CURVE: printf("\nThe curve identifier is: %d\n", (intersect_data[i])->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[i]); } if(num_intersects != 0) { /* Free the array. */ UF_free(intersect_data); } }