|
leaf
发表于 2014-11-26 07:50:53
tag_t newPartTag = NULL_TAG;
6 Z. u2 q+ _% q& U% Q& B3 f tag_t cylTag = NULL_TAG;$ R' A1 P- g! F, A+ n
tag_t bodyTag = NULL_TAG;
( _! r, G6 ^4 ~% y2 M double cylOrigin[3] = {20, 30, 40};
* G# `, \! u7 N' u" r char cylDiam[256] = "50";$ P" v+ r8 W+ r8 v( Q3 Q6 w
double cylDirection[3] = {0, 0 ,1};
& }4 x, x3 p) z* `4 h5 O# b double height = 60;3 o& w5 C% z3 N- M. h
% n$ E) F! w8 L5 r: r1 i6 H H6 J: h: R! G
char cylHeight[256];0 `, Q; B; s: `' F7 @: ^
sprintf_s(cylHeight, sizeof(cylHeight), "%f", height);5 H/ K, o! K+ d9 {5 J: q* N
//创建part' O4 T) S' ^$ V. h
UF_CALL(UF_PART_new("D:\\leaf.part", 1, &newPartTag));6 y3 x/ ^9 \3 d- i) }
//创建圆柱+ Q; o/ R& c% s, C5 ]
UF_CALL(UF_MODL_create_cyl1(UF_NULLSIGN, cylOrigin, cylHeight, cylDiam, cylDirection, &cylTag));
0 U: v3 ~) ?: D. L3 v% n6 n //获取圆柱特征所在的体
% r7 A5 l; B9 |7 P% H UF_CALL(UF_MODL_ask_feat_body(cylTag,&bodyTag));, q) p0 f1 b7 L. c- B( \1 K4 j; v
//获取体上的边
; W3 \+ i6 b* o5 C/ Y$ ]: T uf_list_p_t edge_list ;
+ {$ t* H- u" B UF_CALL(UF_MODL_ask_body_edges(bodyTag, &edge_list));
% w$ j V) d' b+ x5 @& O" g //得到边的数量
( e) W/ f2 d1 {4 T6 p( t; b! z( O" E int edgeCount = 0;
/ r/ I& I: w$ ^9 C UF_CALL(UF_MODL_ask_list_count(edge_list, &edgeCount));5 j& N1 R9 L3 `5 @- T
//打印边的数量4 k4 B- v1 d% ?4 |
char cCount[256];$ w' l* t5 M$ ]* ^% P8 p) Q- ^
sprintf_s(cCount, sizeof(cCount), "cylinder实体上的边的数量:%d", edgeCount);
+ ^2 K# _( x# J uc1601(cCount, 1);, B) i7 k' K: p F
# e4 N$ U" ?; G: R int error;. w& o- E; I/ s) X
double (*point_coords)[3];
) u4 j7 L" t3 C( s2 [2 T8 P, ?" D point_coords= (double (*)[3]) UF_allocate_memory(edgeCount * sizeof(double [3]), &error );4 H& k: W! e2 [0 b* D2 M
//获取圆柱的上两条边的圆心6 Q' |5 B* [" K" @, r; t) w9 Y/ y
int i = 0;
_, e r9 f2 l tag_t curveOriginTag = NULL_TAG;- i: \; p: V. z. H9 `
for (i; i < edgeCount; i++)9 h1 j9 }; O! q4 t; y% ?6 c
{9 J& ~# S& I0 i* \$ P
UF_CALL(UF_MODL_ask_list_item(edge_list, i, &curveOriginTag));
/ J- s0 b$ A5 ~0 V( k4 p6 L% y UF_CALL(UF_CURVE_ask_centroid(curveOriginTag, point_coords[i]));! c5 \9 D. g' l: e. r5 U6 g) c, b
}
* |$ l8 |: z/ F% k6 c //将圆心存放到直线起始点的链表中
3 Z P. R% n( ` UF_CURVE_line_p_t line_coords;
N2 P! W6 H+ ~, h) w& j+ Z+ b! u g0 V line_coords= (UF_CURVE_line_p_t ) UF_allocate_memory(edgeCount * sizeof(double [3]), &error );! l& @) ~7 l2 y2 l: e9 k
line_coords->start_point[0] = point_coords[0][0];
4 J6 R1 V, O+ z1 M9 K3 e line_coords->start_point[1] = point_coords[0][1];
* j4 Z* e0 W) R0 s) R' A3 _ line_coords->start_point[2] = point_coords[0][2];% N! |4 H5 w y/ O6 h h
line_coords->end_point[0] = point_coords[1][0];' ^" Y& T! b* v3 q' V( ?1 c2 ~; o/ n) p
line_coords->end_point[1] = point_coords[1][1];
6 A9 I% d; q# c3 a+ }, k ^ line_coords->end_point[2] = point_coords[1][2];& D1 M6 ~: {# ?$ \
+ f) y6 r+ O0 J3 T) D2 W# k& j5 b2 R) A
tag_t lineTag = NULL_TAG;5 O, q( F- V V8 E8 {
0 ?& _. {& r. P" L [: i3 w2 S //创建直线
W/ ^" m$ a1 c" _& z- n UF_CALL(UF_CURVE_create_line(line_coords, &lineTag));
9 [8 k+ e0 {, O: y5 M1 X
: T4 N( E9 ]5 O( o0 v7 W m //打印直线的端点+ P3 K% q: n8 n5 X# R9 e: z ~0 p2 @
char msg[256];
6 w( i' t* r5 ]) L1 ^" m sprintf_s(msg, sizeof(msg), "创建的直线的起点是:%f、%f、%f,\n终点是:%f、%f、%f.",
( Y h. v: e! \. o! H line_coords->start_point[0],
( G; K; ?: J; e line_coords->start_point[1],. D% S; [+ u1 z1 d: x
line_coords->start_point[2],
4 O3 e' M# B* {( H line_coords->end_point[0],- j+ `8 I" [7 z- n9 f/ Y. ^
line_coords->end_point[1],# K. x# ?' [) l0 H7 h
line_coords->end_point[2]);. p0 q0 p% c5 M& z0 I& z3 B& n, S
UF_CALL(UF_UI_open_listing_window());
' T$ i: U- k' _. M UF_CALL(UF_UI_write_listing_window(msg));7 w) F6 \5 w" O5 c
//UF_CALL(UF_UI_close_listing_window());5 R, f8 g+ \' z: w
" `- r0 `. \. C o' Z
//释放动态内存! S/ O* m9 ?( q/ l: a7 v
UF_MODL_delete_list(&edge_list);! i& W$ t' }, _0 a8 S7 D! I0 w w! Z
UF_free(point_coords);; ?9 t4 q( A! v4 C* W0 a
UF_free(line_coords);
4 o( O7 q. h- a' N- k% z/ F6 r$ X
UF_PART_save();4 v) D& V' a9 D! ^/ r
UF_PART_close_all(); |
评分
-
查看全部评分
|