|
|
leaf
发表于 2014-11-26 07:50:53
tag_t newPartTag = NULL_TAG;1 T* A" s, x* C: n5 j) N
tag_t cylTag = NULL_TAG;- _+ ^" d0 o# _5 q1 l
tag_t bodyTag = NULL_TAG;
. S, D& q Z4 C/ l) A: E; M K double cylOrigin[3] = {20, 30, 40};% f$ z7 n7 T* q5 O
char cylDiam[256] = "50";9 x3 L7 _; I# N* |, y. a
double cylDirection[3] = {0, 0 ,1};
/ o( S$ M: t, s# z i6 Z, U9 Z0 c double height = 60;- |! M4 @ b5 Y. b$ q$ w
4 k8 K+ @/ M; o8 V; ^( p6 k
+ L- k7 q' d4 R4 U- B& q
char cylHeight[256];
: Z- @: N6 y9 @9 L; j sprintf_s(cylHeight, sizeof(cylHeight), "%f", height);6 F0 F4 h/ @. ~, {, @) E; C; [9 q
//创建part9 G/ M( Y7 ~4 W" B8 ]! `: |
UF_CALL(UF_PART_new("D:\\leaf.part", 1, &newPartTag));4 E& ^/ G/ h$ R" p+ _' W
//创建圆柱
/ a; q0 {3 F+ \/ r UF_CALL(UF_MODL_create_cyl1(UF_NULLSIGN, cylOrigin, cylHeight, cylDiam, cylDirection, &cylTag));* ]3 B1 q/ y, K" y, g* k c. j. c6 H" B
//获取圆柱特征所在的体
9 ^7 w( Y: U5 M" @) @) l- R& u UF_CALL(UF_MODL_ask_feat_body(cylTag,&bodyTag));
4 a/ A! q! n$ T# k$ k: r& M$ U+ E //获取体上的边
- V0 u% Q; ?) d7 Y* t+ E' _, P uf_list_p_t edge_list ;
/ f$ \! T$ _3 S# p& s4 m( E UF_CALL(UF_MODL_ask_body_edges(bodyTag, &edge_list));
0 X: o; U7 a4 l% O& r //得到边的数量
) S6 s/ p. e2 w( m' s' S! Q: o. S int edgeCount = 0;
% C& j+ G. m: P- d) A( i# D- @0 w UF_CALL(UF_MODL_ask_list_count(edge_list, &edgeCount));! `$ d/ I9 A& s8 |2 `/ o# p* A# Y" \' `9 p
//打印边的数量
+ b% U/ F% P$ ^ char cCount[256];
! F5 Q" q& |% C, q; V7 e. V' ]. e sprintf_s(cCount, sizeof(cCount), "cylinder实体上的边的数量:%d", edgeCount);
G) j: ~) w" M. u: d uc1601(cCount, 1);$ K' _+ \; l; v) }6 `) r: R# O
, X& j8 `) q6 v* P$ h! ~
int error;
, s2 |3 i' |% ]) _: k r double (*point_coords)[3];
3 K+ u) h9 a2 c6 e4 H point_coords= (double (*)[3]) UF_allocate_memory(edgeCount * sizeof(double [3]), &error );
/ h. K# i% [, S& K9 k" W R //获取圆柱的上两条边的圆心7 ?. F; q3 W9 {& P
int i = 0;/ \7 Z( F+ d. l/ ` G/ B
tag_t curveOriginTag = NULL_TAG;% a# M# M5 N( h9 q( o& R
for (i; i < edgeCount; i++)
, d! {" {+ @: j6 q3 g( e- q2 T {. ?# f7 e9 ^4 d2 d' }
UF_CALL(UF_MODL_ask_list_item(edge_list, i, &curveOriginTag));* B" r) d5 W- \# @0 F o0 w
UF_CALL(UF_CURVE_ask_centroid(curveOriginTag, point_coords[i]));
1 U* X1 M4 E7 k' k) \ }- [* {2 U: s- L( D: d6 n
//将圆心存放到直线起始点的链表中% p& M3 s" X- h k9 |
UF_CURVE_line_p_t line_coords;
+ R: l# R3 F8 E. a* R line_coords= (UF_CURVE_line_p_t ) UF_allocate_memory(edgeCount * sizeof(double [3]), &error );
2 a3 e1 _! c2 Y8 v7 Z9 A line_coords->start_point[0] = point_coords[0][0];
# w4 |' R3 A7 X line_coords->start_point[1] = point_coords[0][1];
- ?! O$ e/ ?" x. ^9 ?! E: X5 Q. ~4 k line_coords->start_point[2] = point_coords[0][2];
8 j. I$ [' O" v/ S* c6 z" W line_coords->end_point[0] = point_coords[1][0];. q \- f t a
line_coords->end_point[1] = point_coords[1][1];
; o, x7 _: N; J' K% e" a line_coords->end_point[2] = point_coords[1][2];
5 w, K U0 a1 l/ h/ I$ e, j
9 z/ D2 [' j4 ~: k2 ] tag_t lineTag = NULL_TAG;1 z: B* `6 t: M8 _
6 }* E# }/ D, P% f) y2 k/ L }
//创建直线
7 I% c% r+ [7 R1 j, A1 U( Q UF_CALL(UF_CURVE_create_line(line_coords, &lineTag));1 i$ u5 i, R# d
& J s, ]* @$ E9 |; u2 W. G; ]
//打印直线的端点
9 s( [# b o+ G$ x2 t char msg[256];
+ [$ X d9 @2 A. q sprintf_s(msg, sizeof(msg), "创建的直线的起点是:%f、%f、%f,\n终点是:%f、%f、%f.",
; l# d, r7 F- z4 Z* O6 C" l, V line_coords->start_point[0],: y; A/ S5 T& B8 ]% f y
line_coords->start_point[1],+ k% r! H* g' U/ ]
line_coords->start_point[2],
5 }' a% m" U- E: c! W line_coords->end_point[0],
: Y$ X! Y) d0 ]8 U line_coords->end_point[1],
' f' y# [9 `8 m G3 E/ N5 [, b+ D9 x line_coords->end_point[2]);
5 {4 J: C8 @ M% \! m UF_CALL(UF_UI_open_listing_window());% X0 o* s' \+ `3 e# }! j
UF_CALL(UF_UI_write_listing_window(msg));2 ^/ u1 Q2 S: v, p7 f( }* Y, l
//UF_CALL(UF_UI_close_listing_window());
2 V {# c" x. B# ^. u9 J) g/ p
0 b" i/ j, {; O; S& v" d# x //释放动态内存5 a; ]" Q) z# a! c
UF_MODL_delete_list(&edge_list);# H' }# f' g/ K" U; n
UF_free(point_coords);
$ e( Y0 j- J1 E; S2 S5 s; D! | UF_free(line_coords);
' U, I9 u2 @& l l0 H6 ~5 d
- ]) z. U' a# B/ p% Q UF_PART_save();
( i% \9 n: X& P, n9 P/ W UF_PART_close_all(); |
评分
-
查看全部评分
|