|
leaf
发表于 2014-11-26 07:50:53
tag_t newPartTag = NULL_TAG;
% f2 m6 v) Y$ S$ k# u. q% _! G8 L" N tag_t cylTag = NULL_TAG;4 a) O# r6 X! Z$ L
tag_t bodyTag = NULL_TAG;7 f8 m$ }8 S$ q" f) ^, R
double cylOrigin[3] = {20, 30, 40};
) t) \9 R: t* s' p char cylDiam[256] = "50";; t, _- o+ Q( h+ C* ^4 G8 N
double cylDirection[3] = {0, 0 ,1}; d) l) S* p- U# C! Q1 e# Y
double height = 60;) _! V3 v, ]$ w9 z# ^
" T$ E. l4 Q! Q! U8 o( I
6 x$ K7 B& A- E; a" V char cylHeight[256];
6 n( w) J: |2 o8 t" X sprintf_s(cylHeight, sizeof(cylHeight), "%f", height);
. a4 u8 C% L1 `7 v3 b! y //创建part
+ g6 c# o; c6 V1 C& y( p! i UF_CALL(UF_PART_new("D:\\leaf.part", 1, &newPartTag));# v- S6 B& B. Z; R7 {5 u
//创建圆柱
M. ?4 v$ c: i8 [: ^ UF_CALL(UF_MODL_create_cyl1(UF_NULLSIGN, cylOrigin, cylHeight, cylDiam, cylDirection, &cylTag));4 [, J; P. Y9 d7 D% {7 o% {
//获取圆柱特征所在的体
) _+ f2 C# |( C. j/ L UF_CALL(UF_MODL_ask_feat_body(cylTag,&bodyTag));( |" C5 o, i+ ^( }
//获取体上的边
! \% w- g4 i, A9 G; u7 E% z uf_list_p_t edge_list ;% ?. X2 f7 l! X. [+ x
UF_CALL(UF_MODL_ask_body_edges(bodyTag, &edge_list));1 F3 ~$ y" R" b( P$ T+ }
//得到边的数量
; V, @6 [/ {; N) @ int edgeCount = 0;" y! Z- L* u) {; A
UF_CALL(UF_MODL_ask_list_count(edge_list, &edgeCount));
% _3 ^- T* U( U( w/ @! a //打印边的数量8 N# r6 x8 g0 \" U4 n0 o/ @
char cCount[256];; s# t+ X7 B4 s8 j% Q
sprintf_s(cCount, sizeof(cCount), "cylinder实体上的边的数量:%d", edgeCount);' ~) a8 K: Q& Z# G9 b' f( B
uc1601(cCount, 1);
K/ B3 m" C$ S+ J) P( s- y
+ a6 U2 l; j; H! R int error;
6 Z; L3 ^- ?* p: w- K0 A double (*point_coords)[3];
) d1 ^8 o9 N) V5 } point_coords= (double (*)[3]) UF_allocate_memory(edgeCount * sizeof(double [3]), &error );
2 x' R0 B) v$ W; q1 Y //获取圆柱的上两条边的圆心; G% @1 t* M2 ?( p2 k# ^ `' C
int i = 0;9 o, X7 O* ~7 X' b* D
tag_t curveOriginTag = NULL_TAG;1 o6 c8 Z( b5 w: u) O4 e) ?5 F
for (i; i < edgeCount; i++)
) k& a9 ^8 e. d ^- l. s& o$ _ {7 X9 c0 d" B) m, z
UF_CALL(UF_MODL_ask_list_item(edge_list, i, &curveOriginTag));( _, \( A1 e' f7 g
UF_CALL(UF_CURVE_ask_centroid(curveOriginTag, point_coords[i]));
h* \: B0 K: }3 t: Y5 |& ^; q- N }* }9 H9 f7 {: P) K, v$ g u
//将圆心存放到直线起始点的链表中* s" Z0 U9 |. @
UF_CURVE_line_p_t line_coords;
1 _$ H ^( Q' {& P4 h# s line_coords= (UF_CURVE_line_p_t ) UF_allocate_memory(edgeCount * sizeof(double [3]), &error );
" V. Q: a9 s4 I$ Z8 M line_coords->start_point[0] = point_coords[0][0];
& F% o& j% L7 B# ]0 U line_coords->start_point[1] = point_coords[0][1];$ G# {1 F2 G2 s6 h) Z- ~
line_coords->start_point[2] = point_coords[0][2];. x) r$ K: |( [
line_coords->end_point[0] = point_coords[1][0];' i7 S# a# t* `4 _5 T @, Z
line_coords->end_point[1] = point_coords[1][1];4 C8 b F0 R: E. m
line_coords->end_point[2] = point_coords[1][2];- A3 h9 g; q6 o+ `, C
, z, w; g3 q2 X/ j; l1 G% J
tag_t lineTag = NULL_TAG;7 b/ A% T# x7 @$ v% d! G
4 T4 V6 q2 D- ~1 y" M( z
//创建直线3 Z# _6 E! I% ]. p4 P. C
UF_CALL(UF_CURVE_create_line(line_coords, &lineTag));6 A, L' ?0 l- n! X+ ?
' I* M( A+ V0 Q
//打印直线的端点
1 \* o3 Y: v( ~& z# e char msg[256];# j$ S1 w. t1 ~0 m& p" i7 \' V
sprintf_s(msg, sizeof(msg), "创建的直线的起点是:%f、%f、%f,\n终点是:%f、%f、%f.",# S4 I2 l5 w9 u Z: Y Y) e
line_coords->start_point[0],, d3 |. V" f. U; ]
line_coords->start_point[1],
* J% l5 B# `$ c; Y, c) J9 e5 g line_coords->start_point[2],
+ Z G* u* H7 V* A- ]2 l line_coords->end_point[0],
" R% n( y* Q1 P- S T. W! f line_coords->end_point[1],
I* J9 w4 a9 ^: z( [, `- E) E! t9 L: t. H line_coords->end_point[2]);/ S: J4 Y. N. G: l% n' a% r
UF_CALL(UF_UI_open_listing_window());
% ?# v. `8 |0 V! M3 K UF_CALL(UF_UI_write_listing_window(msg));
% y2 h4 m; d; d: F5 f //UF_CALL(UF_UI_close_listing_window());" h- u% G8 ?9 ^5 W- X* c ]
. O) ^: l$ X" C1 D+ j; A c
//释放动态内存9 q4 N9 V5 a5 @
UF_MODL_delete_list(&edge_list);
4 [/ M& t, a6 X- E9 U* o UF_free(point_coords);
# z, A L3 \3 t: [# e UF_free(line_coords);
! ], v, k; r8 Z" v4 x5 S# T3 O5 o) ^- V" T5 T1 @* c; {) @$ l
UF_PART_save();% L- N3 T9 ?0 Z/ `2 C
UF_PART_close_all(); |
评分
-
查看全部评分
|