|
|
leaf
发表于 2014-11-26 07:50:53
tag_t newPartTag = NULL_TAG;, Q J3 }' m' i; k0 T0 ~& K$ Z
tag_t cylTag = NULL_TAG;
) x0 W" n# H6 g+ I8 y3 p; y7 b tag_t bodyTag = NULL_TAG;
; [: Q; X4 o f7 `$ h y: h0 } double cylOrigin[3] = {20, 30, 40};
+ q/ B k, H; b8 ` char cylDiam[256] = "50";
; W) l3 @. f4 R/ { double cylDirection[3] = {0, 0 ,1};
+ |: l" Q9 b7 S7 X& l4 N double height = 60;; x: d. G. U0 `! c F
Z* H+ Z" W( C9 { {+ ~ j$ V
$ s8 F2 w# [9 a k0 c char cylHeight[256];
3 V4 _% g3 J0 }% ^ Z" E, n' V sprintf_s(cylHeight, sizeof(cylHeight), "%f", height);
( d; w- a' W) @3 Q5 H //创建part6 ~, k. u& _- D" _+ H
UF_CALL(UF_PART_new("D:\\leaf.part", 1, &newPartTag));
9 \2 d$ h2 D" U9 C9 l7 }4 W+ N/ B //创建圆柱
& h( J3 v6 B3 E; Z- R% A UF_CALL(UF_MODL_create_cyl1(UF_NULLSIGN, cylOrigin, cylHeight, cylDiam, cylDirection, &cylTag));
) Z; v6 K+ k: T. [7 Q5 a: B //获取圆柱特征所在的体' J/ y: o" S5 X
UF_CALL(UF_MODL_ask_feat_body(cylTag,&bodyTag));
2 }2 H4 [$ c4 l //获取体上的边: U6 f0 |) d5 B5 j. ]9 J3 u
uf_list_p_t edge_list ;! [9 s2 R( y' F" t* A1 ~4 }) Y
UF_CALL(UF_MODL_ask_body_edges(bodyTag, &edge_list));
" a( K* M4 H7 J V" V$ h //得到边的数量$ T9 q0 ?0 Z2 u2 ~
int edgeCount = 0;
$ R0 ~8 D5 l( | UF_CALL(UF_MODL_ask_list_count(edge_list, &edgeCount));
; y$ J: J7 Z* [9 U. P //打印边的数量
) M4 `0 c D8 x% i char cCount[256];9 s3 w0 {* Y! {5 X% ~# \2 z$ w
sprintf_s(cCount, sizeof(cCount), "cylinder实体上的边的数量:%d", edgeCount);& A- W% U- l0 T) X2 }- S9 I1 p3 s
uc1601(cCount, 1);) W% b- y: T% v2 Z' C. d: ?) x* k3 o$ |
8 c; a* h8 e0 g( i7 A int error;, ^$ E7 G x, v5 S
double (*point_coords)[3];
: r* E: | l! W+ p8 z' ?# X point_coords= (double (*)[3]) UF_allocate_memory(edgeCount * sizeof(double [3]), &error );/ F) d2 \1 F7 ^' h
//获取圆柱的上两条边的圆心
! h* k& d. _. |! F2 v int i = 0;- ?; h1 Q9 p: `: i: h, g
tag_t curveOriginTag = NULL_TAG;
2 Z v) b- e4 Y3 v! `( Z; E- Q: J! ^ for (i; i < edgeCount; i++)' ^0 Y% r7 @! O8 n& {5 Y9 \$ B
{* c8 {, A" s+ V. V: s1 U
UF_CALL(UF_MODL_ask_list_item(edge_list, i, &curveOriginTag));% p) X G9 E0 A: {6 N9 p) H
UF_CALL(UF_CURVE_ask_centroid(curveOriginTag, point_coords[i]));1 m! u/ x7 {" ^# \
}5 X S/ H2 Q4 b4 E
//将圆心存放到直线起始点的链表中; ]$ r; B* T+ p! [0 l" S7 @* W2 ]1 a
UF_CURVE_line_p_t line_coords;
, I8 l4 n; g1 i/ b& `. { line_coords= (UF_CURVE_line_p_t ) UF_allocate_memory(edgeCount * sizeof(double [3]), &error );
$ f& }2 Z1 w! ^" T+ d line_coords->start_point[0] = point_coords[0][0];9 m$ `3 a9 _- }' C& D" T
line_coords->start_point[1] = point_coords[0][1];1 w; s/ Z. T3 z$ V- c* v% v) @
line_coords->start_point[2] = point_coords[0][2];
9 B8 [: C0 G5 D E- L line_coords->end_point[0] = point_coords[1][0];0 [" }6 g, m: t1 o5 T
line_coords->end_point[1] = point_coords[1][1];
, _6 [1 d. q% e( R; f6 d line_coords->end_point[2] = point_coords[1][2];4 J, J+ D' Y6 Y7 T, j
+ s" n$ L, n. R# O. P+ `5 n9 | tag_t lineTag = NULL_TAG;0 y4 [3 H) D) I2 T" p2 l& R& x
2 L O8 N _5 _- s5 E1 t6 z
//创建直线
9 ], V9 a- Q5 i& P UF_CALL(UF_CURVE_create_line(line_coords, &lineTag));
! m5 G6 `3 R7 a: ]7 d9 Y
- u+ L, S- L$ p3 n& Q1 S6 p //打印直线的端点
) c" |5 o' R6 Z3 y& N0 o8 V0 K& h char msg[256];
! @, z% b, |* ^ T6 y/ J, S& V& t/ l sprintf_s(msg, sizeof(msg), "创建的直线的起点是:%f、%f、%f,\n终点是:%f、%f、%f.",
! H! ?; A/ ] L- W( B line_coords->start_point[0],
( g4 f L8 R. j$ o h* I line_coords->start_point[1],+ Z5 R/ ]( ~; l6 C$ B( s) V
line_coords->start_point[2],+ J5 Q; Y, \6 Q5 m* `) _5 P
line_coords->end_point[0],% L! g. H; l W: `' D. M* Z, V
line_coords->end_point[1],- ^& k8 d$ m; @
line_coords->end_point[2]);- I' ^& c3 j. Z. v6 _1 [. y9 ~) P
UF_CALL(UF_UI_open_listing_window());! h6 J% l0 r" k8 t W4 S
UF_CALL(UF_UI_write_listing_window(msg));2 H' W! t- _/ O# g1 D: s
//UF_CALL(UF_UI_close_listing_window());
/ X u8 O; p# T" W& g2 d
+ B0 U/ Y4 Y8 m. @ //释放动态内存$ a X+ O8 N0 y9 P! ]2 c
UF_MODL_delete_list(&edge_list);
. k) L+ Z# e L0 p' L UF_free(point_coords); d' Y1 }! _) Z7 }2 P
UF_free(line_coords);! {7 H7 `6 C, ?) I7 S. f9 B: q3 l5 a9 Z
0 Y; e9 M: Q* x4 Z UF_PART_save();
8 J7 t1 s! ~# E _: @ UF_PART_close_all(); |
评分
-
查看全部评分
|